diff options
author | Dan J Miller <danjm.com@gmail.com> | 2018-01-16 11:00:07 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@users.noreply.github.com> | 2018-01-16 11:00:07 +0800 |
commit | 77eb7b2db692cc40bf5f8e36c5e695e8f82c76ec (patch) | |
tree | 3e2938e5f04441be0c03dd9abf7db53bdcff2c28 /gulpfile.js | |
parent | a4fd4f013fc0657920a452f04591dc26d4a5639e (diff) | |
download | tangerine-wallet-browser-77eb7b2db692cc40bf5f8e36c5e695e8f82c76ec.tar tangerine-wallet-browser-77eb7b2db692cc40bf5f8e36c5e695e8f82c76ec.tar.gz tangerine-wallet-browser-77eb7b2db692cc40bf5f8e36c5e695e8f82c76ec.tar.bz2 tangerine-wallet-browser-77eb7b2db692cc40bf5f8e36c5e695e8f82c76ec.tar.lz tangerine-wallet-browser-77eb7b2db692cc40bf5f8e36c5e695e8f82c76ec.tar.xz tangerine-wallet-browser-77eb7b2db692cc40bf5f8e36c5e695e8f82c76ec.tar.zst tangerine-wallet-browser-77eb7b2db692cc40bf5f8e36c5e695e8f82c76ec.zip |
[NewUI-flat] Fix gulp build (#2975)
* Only run uglify when building for prod; set environment when building for prod; use gulp-uglify-es.
* Revert change of dist script.
Diffstat (limited to 'gulpfile.js')
-rw-r--r-- | gulpfile.js | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/gulpfile.js b/gulpfile.js index f61e15b69..d64eff025 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -23,7 +23,7 @@ var sass = require('gulp-sass') var autoprefixer = require('gulp-autoprefixer') var gulpStylelint = require('gulp-stylelint') var stylefmt = require('gulp-stylefmt') -var uglify = require('gulp-uglify') +var uglify = require('gulp-uglify-es').default var babel = require('gulp-babel') @@ -234,8 +234,18 @@ var jsDevStrings = jsFiles.map(jsFile => `dev:js:${jsFile}`) var jsBuildStrings = jsFiles.map(jsFile => `build:js:${jsFile}`) jsFiles.forEach((jsFile) => { - gulp.task(`dev:js:${jsFile}`, bundleTask({ watch: true, label: jsFile, filename: `${jsFile}.js` })) - gulp.task(`build:js:${jsFile}`, bundleTask({ watch: false, label: jsFile, filename: `${jsFile}.js` })) + gulp.task(`dev:js:${jsFile}`, bundleTask({ + watch: true, + label: jsFile, + filename: `${jsFile}.js`, + isBuild: false + })) + gulp.task(`build:js:${jsFile}`, bundleTask({ + watch: false, + label: jsFile, + filename: `${jsFile}.js`, + isBuild: true + })) }) // inpage must be built before all other scripts: @@ -269,12 +279,18 @@ gulp.task('zip:edge', zipTask('edge')) gulp.task('zip:opera', zipTask('opera')) gulp.task('zip', gulp.parallel('zip:chrome', 'zip:firefox', 'zip:edge', 'zip:opera')) +// set env var for production +gulp.task('apply-prod-environment', function(done) { + process.env.NODE_ENV = 'production' + done() +}); + // high level tasks gulp.task('dev', gulp.series('build:scss', 'dev:js', 'copy', gulp.parallel('watch:scss', 'copy:watch', 'dev:reload'))) gulp.task('build', gulp.series('clean', 'build:scss', gulp.parallel('build:js', 'copy'))) -gulp.task('dist', gulp.series('build', 'zip')) +gulp.task('dist', gulp.series('apply-prod-environment', 'build', 'zip')) // task generators @@ -367,7 +383,6 @@ function bundleTask(opts) { throw err } }) - // convert bundle stream to gulp vinyl stream .pipe(source(opts.filename)) // inject variables into bundle @@ -378,10 +393,7 @@ function bundleTask(opts) { // loads map from browserify file .pipe(gulpif(debug, sourcemaps.init({ loadMaps: true }))) // Minification - .pipe(babel({ - presets: ['env'] - })) - .pipe(uglify()) + .pipe(gulpif(opts.isBuild, uglify())) // writes .map file .pipe(gulpif(debug, sourcemaps.write('./'))) // write completed bundles |