Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to tell django compressor to create source maps

I want to be able to debug minified compressed javascript code on my production site. Our site uses django compressor to create minified and compressed js files. I read recently about chrome being able to use source maps to help debug such javascript. However I don't know how/if possible to tell the django compressor to create source maps when compressing the js files

like image 753
nivcaner Avatar asked Jan 31 '13 08:01

nivcaner


1 Answers

I don't have a good answer regarding outputting separate source map files, however I was able to get inline working.

Prior to adding source maps my settings.py file used the following precompilers

COMPRESS_PRECOMPILERS = (
    ('text/coffeescript', 'coffee --compile --stdio'),
    ('text/less', 'lessc {infile} {outfile}'),
    ('text/x-sass', 'sass {infile} {outfile}'),
    ('text/x-scss', 'sass --scss {infile} {outfile}'),
    ('text/stylus', 'stylus < {infile} > {outfile}'),
)

After a quick

$ lessc --help

You find out you can put the less and map files in to the output css file. So my new text/less precompiler entry looks like

('text/less', 'lessc --source-map-less-inline --source-map-map-inline {infile} {outfile}'),

Hope this helps.

Edit: Forgot to add, lessc >= 1.5.0 required for this, to upgrade use

$ [sudo] npm update -g less
like image 77
ncavig Avatar answered Sep 21 '22 23:09

ncavig