diff options
author | kumavis <kumavis@users.noreply.github.com> | 2017-08-09 14:30:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-09 14:30:58 +0800 |
commit | 0188e7b94d85b45a783f9e3d5c182a8ffcaeac2e (patch) | |
tree | 428154973b91dfb2f8519777e67da7a6c75530b3 /gulpfile.js | |
parent | 5e9926b0d035a5ba946080e94777ac0bd887d396 (diff) | |
parent | 57f6fce6b2524c4b36b591da5e600d0652f4077e (diff) | |
download | tangerine-wallet-browser-0188e7b94d85b45a783f9e3d5c182a8ffcaeac2e.tar tangerine-wallet-browser-0188e7b94d85b45a783f9e3d5c182a8ffcaeac2e.tar.gz tangerine-wallet-browser-0188e7b94d85b45a783f9e3d5c182a8ffcaeac2e.tar.bz2 tangerine-wallet-browser-0188e7b94d85b45a783f9e3d5c182a8ffcaeac2e.tar.lz tangerine-wallet-browser-0188e7b94d85b45a783f9e3d5c182a8ffcaeac2e.tar.xz tangerine-wallet-browser-0188e7b94d85b45a783f9e3d5c182a8ffcaeac2e.tar.zst tangerine-wallet-browser-0188e7b94d85b45a783f9e3d5c182a8ffcaeac2e.zip |
Merge branch 'master' into NewUI-flat
Diffstat (limited to 'gulpfile.js')
-rw-r--r-- | gulpfile.js | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/gulpfile.js b/gulpfile.js index f351c2e2f..a8333e950 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -258,26 +258,27 @@ function zipTask(target) { } } -function generateBundler(opts) { - var browserifyOpts = assign({}, watchify.args, { +function generateBundler(opts, performBundle) { + const browserifyOpts = assign({}, watchify.args, { entries: ['./app/scripts/'+opts.filename], plugin: 'browserify-derequire', debug: debug, fullPaths: debug, }) - return browserify(browserifyOpts) -} - -function discTask(opts) { - let bundler = generateBundler(opts) + let bundler = browserify(browserifyOpts) if (opts.watch) { bundler = watchify(bundler) - // on any dep update, runs the bundler + // on any file update, re-runs the bundler bundler.on('update', performBundle) } + return bundler +} + +function discTask(opts) { + const bundler = generateBundler(opts, performBundle) // output build logs to terminal bundler.on('log', gutil.log) @@ -299,14 +300,7 @@ function discTask(opts) { function bundleTask(opts) { - let bundler = generateBundler(opts) - - if (opts.watch) { - bundler = watchify(bundler) - // on any file update, re-runs the bundler - bundler.on('update', performBundle) - } - + const bundler = generateBundler(opts, performBundle) // output build logs to terminal bundler.on('log', gutil.log) @@ -316,6 +310,17 @@ function bundleTask(opts) { return ( bundler.bundle() + + // handle errors + .on('error', (err) => { + beep() + if (opts.watch) { + console.warn(err.stack) + } else { + throw err + } + }) + // convert bundle stream to gulp vinyl stream .pipe(source(opts.filename)) // inject variables into bundle @@ -324,7 +329,7 @@ function bundleTask(opts) { .pipe(buffer()) // sourcemaps // loads map from browserify file - .pipe(gulpif(debug, sourcemaps.init({loadMaps: true}))) + .pipe(gulpif(debug, sourcemaps.init({ loadMaps: true }))) // writes .map file .pipe(gulpif(debug, sourcemaps.write('./'))) // write completed bundles @@ -338,3 +343,7 @@ function bundleTask(opts) { ) } } + +function beep () { + process.stdout.write('\x07') +} |