Generate source maps from Closure Compiler

(imported from commit 0e4de860b1dba85aa43b60a2c819ac44403186c5)
This commit is contained in:
Keegan McAllister
2013-03-27 13:40:17 -04:00
parent f76984b4ef
commit aa3c446665
3 changed files with 23 additions and 1 deletions

19
zephyr/lib/minify.py Normal file
View File

@@ -0,0 +1,19 @@
from django.conf import settings
from hashlib import sha1
from os import path
from pipeline.compressors import SubProcessCompressor
class ClosureSourceMapCompressor(SubProcessCompressor):
def compress_js(self, js):
# js is the full text of the JavaScript source, and we can't
# easily get either the input file names or the output file
# name. So we just pick a unique arbitrary name. This is
# okay because we can figure out from the source map file
# contents which JavaScript files it corresponds to.
source_map = path.join(settings.PIPELINE_CLOSURE_SOURCE_MAP_DIR,
sha1(js).hexdigest() + '.map')
command = '%s --create_source_map %s' % (
settings.PIPELINE_CLOSURE_BINARY, source_map)
return self.execute_command(command, js)