Skip to content

Commit

Permalink
Merge pull request mozilla#6939 from LilyBin/uglifyjs
Browse files Browse the repository at this point in the history
Use UglifyJS to minify files in minified target
  • Loading branch information
timvandermeij committed Feb 13, 2016
2 parents 2f145d8 + e403f52 commit cd9d134
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
30 changes: 11 additions & 19 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,15 +652,9 @@ function cleanupCSSSource(file) {
//
// make minified
// Builds the minified production viewer that should be compatible with most
// modern HTML5 browsers. Requires Google Closure Compiler.
// modern HTML5 browsers.
//
target.minified = function() {
var compilerPath = process.env['CLOSURE_COMPILER'];
if (!compilerPath) {
echo('### Closure Compiler is not set. Specify CLOSURE_COMPILER variable');
exit(1);
}

target.bundle({});
target.locale();

Expand Down Expand Up @@ -703,22 +697,20 @@ target.minified = function() {
MINIFIED_DIR + BUILD_DIR + 'pdf.js',
MINIFIED_DIR + '/web/viewer.js'
];
var cmdPrefix = 'java -jar \"' + compilerPath + '\" ' +
'--language_in ECMASCRIPT5 ' +
'--warning_level QUIET ' +
'--compilation_level SIMPLE_OPTIMIZATIONS ';

echo();
echo('### Minifying js files');

exec(cmdPrefix + viewerFiles.map(function(s) {
return '--js \"' + s + '\"';
}).join(' ') +
' --js_output_file \"' + MINIFIED_DIR + '/web/pdf.viewer.js\"');
exec(cmdPrefix + '--js \"' + MINIFIED_DIR + '/build/pdf.js' + '\" ' +
'--js_output_file \"' + MINIFIED_DIR + '/build/pdf.min.js' + '\"');
exec(cmdPrefix + '--js \"' + MINIFIED_DIR + '/build/pdf.worker.js' + '\" ' +
'--js_output_file \"' + MINIFIED_DIR + '/build/pdf.worker.min.js' + '\"');
var UglifyJS = require('uglify-js');
// V8 chokes on very long sequences. Works around that.
var optsForHugeFile = {compress: {sequences: false}};

UglifyJS.minify(viewerFiles).code
.to(MINIFIED_DIR + '/web/pdf.viewer.js');
UglifyJS.minify(MINIFIED_DIR + '/build/pdf.js').code
.to(MINIFIED_DIR + '/build/pdf.min.js');
UglifyJS.minify(MINIFIED_DIR + '/build/pdf.worker.js', optsForHugeFile).code
.to(MINIFIED_DIR + '/build/pdf.worker.min.js');

echo();
echo('### Cleaning js files');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rimraf": "^2.4.1",
"shelljs": "~0.4.0",
"typogr": "~0.6.5",
"uglify-js": "^2.6.1",
"wintersmith": "^2.0.0",
"yargs": "^3.14.0"
},
Expand Down

0 comments on commit cd9d134

Please sign in to comment.