client/build: don't minify JS for debug build

This commit is contained in:
rr- 2016-04-07 18:51:29 +02:00
parent 26ac304e69
commit c1816a292f

View file

@ -95,15 +95,17 @@ function bundleCss() {
}); });
} }
function bundleJs() { function bundleJs(config) {
const browserify = require('browserify'); const browserify = require('browserify');
const uglifyjs = require('uglify-js'); const uglifyjs = require('uglify-js');
glob('./js/**/*.js', {}, function(er, files) { glob('./js/**/*.js', {}, function(er, files) {
const outputFile = fs.createWriteStream('./public/bundle.min.js'); const outputFile = fs.createWriteStream('./public/bundle.min.js');
browserify().add(files).bundle().pipe(outputFile); browserify().add(files).bundle().pipe(outputFile);
outputFile.on('finish', function() { outputFile.on('finish', function() {
const result = uglifyjs.minify('./public/bundle.min.js'); if (!config.debug) {
fs.writeFileSync('./public/bundle.min.js', result.code); const result = uglifyjs.minify('./public/bundle.min.js');
fs.writeFileSync('./public/bundle.min.js', result.code);
}
console.info('Bundled JS'); console.info('Bundled JS');
}); });
}); });
@ -122,5 +124,5 @@ const config = getConfig();
bundleConfig(config); bundleConfig(config);
bundleHtml(config); bundleHtml(config);
bundleCss(); bundleCss();
bundleJs(); bundleJs(config);
copyFile('./img/favicon.png', './public/favicon.png'); copyFile('./img/favicon.png', './public/favicon.png');