Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing scss files with custom path prefixes not working #22

Open
eagle-r opened this issue Aug 9, 2016 · 2 comments
Open

Importing scss files with custom path prefixes not working #22

eagle-r opened this issue Aug 9, 2016 · 2 comments

Comments

@eagle-r
Copy link

eagle-r commented Aug 9, 2016

From my reading of the docs, I thought I could add the following to my settings,

STATICFILES_DIRS = (
    ('css/bootstrap', _Path(BASE_DIR, 'node_modules/bootstrap-sass/assets/stylesheets/bootstrap')),
    ('scss', _Path(BASE_DIR, 'django-site/django_app/static/scss')),
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
)

Then, in my main scss file (django-site/django_app/static/scss/main.scss), use

// @import "../../../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/variables";
@import "css/bootstrap/variables";

However, if I do, I get a CompileError: File to import not found or unreadable: css/bootstrap/variables even though the commented out relative path works fine.

@gasman
Copy link
Member

gasman commented Aug 9, 2016

Hi @eagle-r - I think this is due to the use of prefixes in your STATICFILES_DIRS setting. Currently, django-libsass just passes a plain list of include paths to the libsass compiler, so while we can add node_modules/bootstrap-sass/assets/stylesheets/bootstrap to the search path, we can't tell it "when you see the path css/bootstrap, map that to node_modules/bootstrap-sass/assets/stylesheets/bootstrap instead". The easiest workaround is probably to write

STATICFILES_DIRS = [
    _Path(BASE_DIR, 'node_modules/bootstrap-sass/assets/stylesheets'),
    _Path(BASE_DIR, 'django-site/django_app/static'),
]

and use @import "bootstrap/variables".

However, I've just seen that libsass-python now supports import callbacks as of version 0.10, which would allow us to support these kinds of mappings. So that's something for the wish list...

@gasman gasman changed the title Importing scss files from outside of Django apps not working Importing scss files with custom path prefixes not working Aug 9, 2016
@eagle-r
Copy link
Author

eagle-r commented Aug 9, 2016

Thanks for the quick response. You were absolutely correct about the prefixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants