diff options
build - use uglifyify and gulp-multi-process for better performance
Diffstat (limited to 'gulpfile.js')
-rw-r--r-- | gulpfile.js | 29 |
1 files changed, 17 insertions, 12 deletions
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 |