Skip to content

Commit

Permalink
Merge pull request #8831 from Snuffleupagus/uglify-es
Browse files Browse the repository at this point in the history
Update the `gulp minified` command to use uglify-es
  • Loading branch information
timvandermeij authored Aug 27, 2017
2 parents 7c7ba9a + 70e8032 commit f54dfc6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,25 +702,27 @@ gulp.task('minified-pre', ['buildnumber', 'locale'], function () {
});

gulp.task('minified-post', ['minified-pre'], function () {
var viewerFiles = [
MINIFIED_DIR + BUILD_DIR + 'pdf.js',
MINIFIED_DIR + '/web/viewer.js'
];
var pdfFile = fs.readFileSync(MINIFIED_DIR + '/build/pdf.js').toString();
var pdfWorkerFile =
fs.readFileSync(MINIFIED_DIR + '/build/pdf.worker.js').toString();
var viewerFiles = {
'pdf.js': pdfFile,
'viewer.js': fs.readFileSync(MINIFIED_DIR + '/web/viewer.js').toString(),
};

console.log();
console.log('### Minifying js files');

var UglifyJS = require('uglify-js');
var UglifyES = require('uglify-es');
// V8 chokes on very long sequences. Works around that.
var optsForHugeFile = { compress: { sequences: false, }, };

fs.writeFileSync(MINIFIED_DIR + '/web/pdf.viewer.js',
UglifyJS.minify(viewerFiles).code);
UglifyES.minify(viewerFiles).code);
fs.writeFileSync(MINIFIED_DIR + '/build/pdf.min.js',
UglifyJS.minify(MINIFIED_DIR + '/build/pdf.js').code);
UglifyES.minify(pdfFile).code);
fs.writeFileSync(MINIFIED_DIR + '/build/pdf.worker.min.js',
UglifyJS.minify(MINIFIED_DIR + '/build/pdf.worker.js',
optsForHugeFile).code);
UglifyES.minify(pdfWorkerFile, optsForHugeFile).code);

console.log();
console.log('### Cleaning js files');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"systemjs-plugin-babel": "0.0.21",
"ttest": "^1.1.0",
"typogr": "^0.6.6",
"uglify-js": "^2.6.1",
"uglify-es": "^3.0.28",
"vinyl-fs": "^2.4.4",
"webpack": "^2.2.1",
"webpack-stream": "^3.2.0",
Expand Down

1 comment on commit f54dfc6

@timvandermeij
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't comment unrelated questions on commits. Use IRC for these kinds of questions.

Please sign in to comment.