1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

build - factor watcify into bundler generation

This commit is contained in:
kumavis 2017-08-08 17:53:34 -07:00
parent 4a4736195f
commit 59e83d2b80

View File

@ -248,26 +248,27 @@ function zipTask(target) {
} }
} }
function generateBundler(opts) { function generateBundler(opts, performBundle) {
var browserifyOpts = assign({}, watchify.args, { const browserifyOpts = assign({}, watchify.args, {
entries: ['./app/scripts/'+opts.filename], entries: ['./app/scripts/'+opts.filename],
plugin: 'browserify-derequire', plugin: 'browserify-derequire',
debug: debug, debug: debug,
fullPaths: debug, fullPaths: debug,
}) })
return browserify(browserifyOpts) let bundler = browserify(browserifyOpts)
}
function discTask(opts) {
let bundler = generateBundler(opts)
if (opts.watch) { if (opts.watch) {
bundler = watchify(bundler) bundler = watchify(bundler)
// on any dep update, runs the bundler // on any file update, re-runs the bundler
bundler.on('update', performBundle) bundler.on('update', performBundle)
} }
return bundler
}
function discTask(opts) {
const bundler = generateBundler(opts, performBundle)
// output build logs to terminal // output build logs to terminal
bundler.on('log', gutil.log) bundler.on('log', gutil.log)
@ -289,14 +290,7 @@ function discTask(opts) {
function bundleTask(opts) { function bundleTask(opts) {
let bundler = generateBundler(opts) const bundler = generateBundler(opts, performBundle)
if (opts.watch) {
bundler = watchify(bundler)
// on any file update, re-runs the bundler
bundler.on('update', performBundle)
}
// output build logs to terminal // output build logs to terminal
bundler.on('log', gutil.log) bundler.on('log', gutil.log)
@ -316,7 +310,7 @@ function bundleTask(opts) {
throw err throw err
} }
}) })
// convert bundle stream to gulp vinyl stream // convert bundle stream to gulp vinyl stream
.pipe(source(opts.filename)) .pipe(source(opts.filename))
// inject variables into bundle // inject variables into bundle