From bd6f5547667bdae00e8990551f3a0ea39ab8d971 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 30 Mar 2018 22:19:02 -0700 Subject: build - use uglifyify and gulp-multi-process for better performance --- gulpfile.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 1eb0a974b..3a3725c0a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -28,8 +28,14 @@ const uglify = require('gulp-uglify-es').default const babel = require('gulp-babel') const debug = require('gulp-debug') const pify = require('pify') +const gulpMultiProcess = require('gulp-multi-process') const endOfStream = pify(require('end-of-stream')) +function gulpParallel (...args) { + return function spawnGulpChildProcess(cb) { + return gulpMultiProcess(args, cb, true) + } +} const browserPlatforms = [ 'firefox', @@ -418,7 +424,7 @@ gulp.task('build', gulp.series( 'clean', 'build:scss', - gulp.parallel( + gulpParallel( 'build:extension:js', 'build:mascara:js', 'copy' @@ -476,6 +482,16 @@ function generateBundler(opts, performBundle) { let bundler = browserify(browserifyOpts) + // Minification + if (opts.minifyBuild) { + bundler.transform('uglifyify', { + global: true, + mangle: { + reserved: [ 'MetamaskInpageProvider' ] + }, + }) + } + if (opts.watch) { bundler = watchify(bundler) // on any file update, re-runs the bundler @@ -544,7 +560,6 @@ function bundleTask(opts) { // buffer file contents (?) .pipe(buffer()) - // Initialize Source Maps if (opts.buildSourceMaps) { buildStream = buildStream @@ -552,16 +567,6 @@ function bundleTask(opts) { .pipe(sourcemaps.init({ loadMaps: true })) } - // Minification - if (opts.minifyBuild) { - buildStream = buildStream - .pipe(uglify({ - mangle: { - reserved: [ 'MetamaskInpageProvider' ] - }, - })) - } - // Finalize Source Maps (writes .map file) if (opts.buildSourceMaps) { buildStream = buildStream -- cgit