jrief / django-sass-processor

SASS processor to compile SCSS files into *.css, while rendering, or offline.
MIT License
402 stars 64 forks source link

I cannot make it work using a basic structure #60

Closed AnderUstarroz closed 7 years ago

AnderUstarroz commented 7 years ago

I don't really like the idea of having my scss files on a public static folder, but it seems to be the default. I have tried the following structure in my project:

/my-project/my-project/scss/styles.scss
/my-project/my-project/static/css/styles.css (autogenerated)
/my-project/my-project/templates/layout.html

This is my config in settings.py:

BASE_DIR = '/var/www/my-project'
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'sass_processor.finders.CssFinder'
]
SASS_PRECISION = 8

SASS_PROCESSOR_INCLUDE_DIRS = [
    os.path.join(BASE_DIR, 'my-project/scss'),
]

And this is the link withinlayout.html:

<link href="{% sass_src 'styles.scss' %}" rel="stylesheet" type="text/css" />

But when running python manage.py compilescss 0 files are compiled. Could you help me out to find what is wrong in my config? When I use {% sass_src 'styles.scss' %} the file "styles.scss" will be searched using the SASS_PROCESSOR_INCLUDE_DIRS right? Or there is no chance to keep the SCSS files outside from the static folder?

AndreasBackx commented 7 years ago

When you have DEBUG set to True, are the CSS files created? If so, then the problem lies with compilescss, if not then the problem lies with your config. But it seems fine. Could you perhaps try adding SASS_PROCESSOR_ENABLED = True?

django-compressor also requires django-compressor to be installed, but I assume you have that installed because it doesn't seem to be throwing any errors.

jrief commented 7 years ago

SASS_PROCESSOR_INCLUDE_DIRS is bypassed to the compiler to look for further scss files which are @import "..."-ed, from other scss files. Therefore your setup doesn't work. You should add your scss files to the static folder just as if they would be css files.