Django-compressor: Sass sourcemap

Created on 1 Oct 2018  ·  7Comments  ·  Source: django-compressor/django-compressor

Hi, I have this setting:

COMPRESS_PRECOMPILERS = (
   ('text/x-sass', 'sassc -m auto {infile} {outfile}'),
)

It generates correctly the sass file but the .map file is not generated.

If I change the setting to:

COMPRESS_PRECOMPILERS = (
   ('text/x-sass', 'sassc -m inline {infile} {outfile}'),
)

It shows the sourcemap inside the sass file, which is ok, but the source file path is wrong, it is an absolute path instead of a relative path so it does not work propertly.

Any ideas how to fix/solve that?

bug

All 7 comments

hm, that seems to be a problem of sassc, which i don't know at all. or what do you think how django-compressor could solve this?

If I run the same command directly into the shell it generates the file correctly.

Can you explain me how the precompilers commands are run?

no, sorry. but maybe the CssAbsoluteFilter is the problem? you could try using the CssRelativeFilter instead.

I tried but gives the same results, at the end of the css file shows /*# sourceMappingURL=tmp8w4nfn41.css.map */ which seems like the wrong file name and also at the same directory the file does not exists.

alright, then i'm out of ideas and this would require some debugging. feel free to do that, ping me if you need anything, although i don't know the code much better than you do ;)

@camilonova Even though it's not related to this problem, have a look at https://github.com/jrief/django-sass-processor

This app generates *.css.map files on the fly and works well together with django-compressor. However, it compiles the files, before django-compressor steps in.

Disclaimer: I'm the author of that library.

You should use:

sass --embed-source-map {infile} {outfile}

This will include the source map into the outfile and fixes this issue.

Was this page helpful?
0 / 5 - 0 ratings