From 56882ee4899d3299a5b77e9d6d6d17bc7e4ab08b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 14 Feb 2017 16:09:27 +0200 Subject: [PATCH] feature(webpack) turn of uglify when NODE_ENV=debug --- webpack.config.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index d3c8a0f4..f2cf0c1a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -12,6 +12,18 @@ const isDebug = env.NODE_ENV === 'debug'; const dist = path.resolve(__dirname, 'dist'); const distDebug = path.resolve(__dirname, 'dist-debug'); const devtool = isDebug ? 'eval' : 'source-map'; +const notEmpty = (a) => a; +const clean = (array) => array.filter(notEmpty); + +const plugins = clean([ + !isDebug && new UglifyJsPlugin({ + sourceMap: true + }), + new webpack.optimize.CommonsChunkPlugin({ + name: 'cloudcmd', + filename: 'cloudcmd.js', + }), +]); module.exports = { devtool, @@ -38,15 +50,7 @@ module.exports = { path: isDebug ? distDebug : dist, libraryTarget: 'umd' }, - plugins: [ - new UglifyJsPlugin({ - sourceMap: true - }), - new webpack.optimize.CommonsChunkPlugin({ - name: 'cloudcmd', - filename: 'cloudcmd.js', - }), - ], + plugins, module: { loaders: [{ test: /\.js$/,