'Django SASS processor does not update CSS files in production
I am using django-sass-processor (https://github.com/jrief/django-sass-processor) in order to generate .css from .scss files. The css wiles were generated on the fly in production, based on the modified date of the scss file (as I understand it from the documentation). However, this on-the-fly-generation of files suddenly stopped working. I have moved my static folder to a different location, so I suspect that is a problem, but my regular static operations (collectstatic) works just fine - it's just the css file generation.
Here are the relevant variables from my settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'sass_processor',
....
]
STATIC_ROOT = '/mnt/hd5/static/'
STATIC_URL = '/static/'
SASS_PROCESSOR_ROOT = '/mnt/hd5/static/css/'
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'sass_processor.finders.CssFinder',
]
The following file is located in /mnt/hd5/static/css:
stylesheet.scss
If I look at the latest filedate it is indeed the latest version, being modified more recently than the .css files. When I run collectstatic (not even sure that is needed?), it doesn't pick up any modifications.
Is there a glaring problem that can be seen above? Or alternatively is there a way I can record/view any error that is generated in the process?
Solution 1:[1]
STATIC_ROOT is where Django stores collected static files to serve - it's not where Django (or django-sass-processor`) will look for source files.
Similarly SASS_PROCESSOR_ROOT is where the processor will store the generated CSS files - not where it will look for source SCSS files.
The file you want the processor to look for and process needs to be in one of the directories that the STATICFILES_FINDERS will look in.
So, if you have an app called myapp then your source files should be at myapp/static/css/stylesheet.scss - the processor will find it here and a generated CSS file will be stored in the directory set as SASS_PROCESSOR_ROOT (this is where the AppDirectoriesFinder looks).
Alternatively, if you prefer not to store the source files inside a specific app, the processor will also look in any directory you have added to the STATICFILES_DIRS setting (this is where the FileSystemFinder looks).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | solarissmoke |
