From e6be94d1392d443bc1af8a26725b8548e9c247ce Mon Sep 17 00:00:00 2001 From: rr- Date: Sat, 14 May 2016 14:47:36 +0200 Subject: [PATCH] client/build: always compress vendor JS --- client/build.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/client/build.js b/client/build.js index d49a5020..14b59b86 100644 --- a/client/build.js +++ b/client/build.js @@ -103,12 +103,12 @@ function bundleCss() { }); } -function writeJsBundle(b, path, message) { +function writeJsBundle(b, path, message, compress) { const uglifyjs = require('uglify-js'); let outputFile = fs.createWriteStream(path); b.bundle().pipe(outputFile); outputFile.on('finish', function() { - if (!config.debug) { + if (compress) { const result = uglifyjs.minify(path); fs.writeFileSync(path, result.code); } @@ -134,7 +134,8 @@ function bundleJs(config) { for (let lib of external) { b.require(lib); } - writeJsBundle(b, './public/vendor.min.js', 'Bundled vendor JS'); + writeJsBundle( + b, './public/vendor.min.js', 'Bundled vendor JS', true); } { @@ -143,10 +144,11 @@ function bundleJs(config) { if (config.transpile) { b = b.transform(babelify); } - b.external(external); - b.on('dep', dep => { console.log(dep.file); }); - b.add(files); - writeJsBundle(b, './public/app.min.js', 'Bundled app JS'); + writeJsBundle( + b.external(external).add(files), + './public/app.min.js', + 'Bundled app JS', + !config.debug); } }); }