mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Generate source maps from Closure Compiler
(imported from commit 0e4de860b1dba85aa43b60a2c819ac44403186c5)
This commit is contained in:
		@@ -279,8 +279,9 @@ PIPELINE_JS = {
 | 
			
		||||
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yui.YUICompressor'
 | 
			
		||||
PIPELINE_YUI_BINARY     = '/usr/bin/env yui-compressor'
 | 
			
		||||
 | 
			
		||||
PIPELINE_JS_COMPRESSOR  = 'pipeline.compressors.closure.ClosureCompressor'
 | 
			
		||||
PIPELINE_JS_COMPRESSOR  = 'zephyr.lib.minify.ClosureSourceMapCompressor'
 | 
			
		||||
PIPELINE_CLOSURE_BINARY = os.path.join(SITE_ROOT, '../tools/closure-compiler/run')
 | 
			
		||||
PIPELINE_CLOSURE_SOURCE_MAP_DIR = 'prod-static/source-map'
 | 
			
		||||
 | 
			
		||||
# Disable stuffing the entire JavaScript codebase inside an anonymous function.
 | 
			
		||||
# We need modules to be externally visible, so that methods can be called from
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,8 @@ exec >update-prod-static.log
 | 
			
		||||
# running app with PipelineCachedStorage unhappy.  So if you
 | 
			
		||||
# remove a static file, you need to manually remove it from
 | 
			
		||||
# prod-static/collected on the app servers.
 | 
			
		||||
rm -rf prod-static/source-map
 | 
			
		||||
mkdir -p prod-static/source-map
 | 
			
		||||
./manage.py collectstatic --noinput
 | 
			
		||||
 | 
			
		||||
# Copy the files we want to expose
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										19
									
								
								zephyr/lib/minify.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								zephyr/lib/minify.py
									
									
									
									
									
										Normal 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)
 | 
			
		||||
		Reference in New Issue
	
	Block a user