Django-compressor: disable caching using precompilers

I am using django-compressor to compile scss files. Each time I modify a scss file, django-compressor creates a css file in /static/CACHE/css/123456.css .

This is normal for pruduction mode, but when I develop locally, I have a revision for every change I make.

So, in development mode, how can I force the output to a file with the same name?

This is not a revison control problem ...

 COMPRESS_PRECOMPILERS = ( ('text/x-sass', 'sass --compass "{infile}" "{outfile}"'), ('text/x-scss', 'sass --scss --compass "{infile}" "{outfile}"'), ) 
+4
source share
3 answers

The file name for the cached file is actually based on its contents. From the Django Compressor docs:

Create a combined file if necessary

If necessary, a file is created. All precompilers are called and all filters are executed, and the hash is determined from the contents. This in turn helps to determine the file name, which is saved only if it was not already. Then the HTML output is output (and also stored in the cache). And here it is!

http://django-compressor.readthedocs.org/en/latest/behind-the-scenes/#third-step-generating-the-combined-file-if-needed

I do not think that you can force Django Compressor to use the specified name without changing the code.

0
source

Your SCSS files still need to go through the appropriate precompiler before you get a working output for your static assets.

In a properly configured development environment, you should respect that the static output directory is not hosted / distributed with your application sources, and the resulting CSS files will not be removed from your sources somewhere in a way that is not version controlled.

EDIT:

That's right, so I missed the correct problem. The only solution is to disable the compressor in development, including clearing the MIME precompiler mappings and resorting to conditionally including client-side compilers in your main template.

This will allow you to refer to the original, unauthorized by LESS and CoffeeScript in development, but, unfortunately, I can not find the SASS compiler on the client side.

0
source

This can be achieved, but it requires a bit of customization. I have this fine tuning. I use the local dev mode on dev, and in production (geroku) autonomous compression.

See the bottom of this issue for code. https://github.com/django-compressor/django-compressor/issues/226

0
source

Source: https://habr.com/ru/post/1483531/


All Articles