summaryrefslogtreecommitdiff
path: root/client/build.js
diff options
context:
space:
mode:
authorrr- <rr-@sakuya.pl>2016-05-14 14:47:36 +0200
committerrr- <rr-@sakuya.pl>2016-05-14 14:47:36 +0200
commite6be94d1392d443bc1af8a26725b8548e9c247ce (patch)
tree499ea9bfa71bb89174adb82943821cbd0e6b837d /client/build.js
parent914bee4c640100572a664254837467237d1d0ab6 (diff)
client/build: always compress vendor JS
Diffstat (limited to 'client/build.js')
-rw-r--r--client/build.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/client/build.js b/client/build.js
index d49a502..14b59b8 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);
}
});
}