Skip to content

Commit 81cfbe2

Browse files
committed
Merge pull request #1 from crschmidt/closurews
Modify build script to support minimizing with jsmin before passing to closure web service (Closes #3422)
2 parents 91f610f + 4447d3c commit 81cfbe2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

build/build.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,20 @@ def build(config_file = None, output_file = None, options = None):
5555
elif use_compressor == "minimize":
5656
minimized = minimize.minimize(merged)
5757
elif use_compressor == "closure_ws":
58-
minimized = closure_ws.minimize(merged)
58+
if len(merged) > 1000000: # The maximum file size for this web service is 1000 KB.
59+
print "\nPre-compressing using jsmin"
60+
merged = jsmin.jsmin(merged)
61+
print "\nIs being compressed using Closure Compiler Service."
62+
try:
63+
minimized = closure_ws.minimize(merged)
64+
except Exception, E:
65+
print "\nAbnormal termination."
66+
sys.exit("ERROR: Closure Compilation using Web service failed!\n%s" % E)
67+
if len(minimized) <= 2:
68+
print "\nAbnormal termination due to compilation errors."
69+
sys.exit("ERROR: Closure Compilation using Web service failed!")
70+
else:
71+
print '\nClosure Compilation using Web service has completed successfully.'
5972
elif use_compressor == "closure":
6073
minimized = closure.minimize(merged)
6174
else: # fallback

0 commit comments

Comments
 (0)