python - Better way to deploy compressed assets - Django Compressor -
so have tricky problem not able find better solution for.
i using django-compressor
great job in compressing/minifying files. problem facing during deployment. time, have been using compress
tag on production , curl on pages make sure regenerates correct css/js. way, new users don't have feel brunt of compression process.
i know has management command can pre-compress files, can pushed cdn , perhaps preload them behind scenes on landing/login pages.
here problem, in of javascript code, using context vars , django tags [both custom , native].
var first = '{% some_tag some_context_var %}'; var name = '{{some_context_var}}';
this causes error since during compression tries execute tag doesn't have values. come compress_offline_context
not dynamic.
did encounter issue before. how do compression if code mixed in django tags/context variables?
found way resolve this.
basically moved variables own script blocks outside of compressor , use variables inside compression code. e.g.
<script type="text/javascript"> var some_var = '{% ctx_var %}'; </script> {% compress js %} //before do_something_function('{% ctx_var %}') do_something_function(some_var);
Comments
Post a Comment