diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-03-18 10:47:08 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-03-18 10:47:08 -0400 |
commit | 5b824cb8552f5dd81d7c1d7800b808d4defc17ad (patch) | |
tree | c86c65999261591726826678d87073dd0d4b0a8a /webapp/webpack.config.js | |
parent | 53d7718e57d4225eb5c020324d32cbe5b5eca7ad (diff) | |
parent | 77ffdc699032f9a669caa7a640cfe734da49cc5a (diff) | |
download | chat-5b824cb8552f5dd81d7c1d7800b808d4defc17ad.tar.gz chat-5b824cb8552f5dd81d7c1d7800b808d4defc17ad.tar.bz2 chat-5b824cb8552f5dd81d7c1d7800b808d4defc17ad.zip |
Merge pull request #2470 from mattermost/plt-2380
PLT-2380 Improvements to webpack build system + watch mode
Diffstat (limited to 'webapp/webpack.config.js')
-rw-r--r-- | webapp/webpack.config.js | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/webapp/webpack.config.js b/webapp/webpack.config.js index 5e1df9bfe..4a21d44c7 100644 --- a/webapp/webpack.config.js +++ b/webapp/webpack.config.js @@ -5,14 +5,20 @@ const CopyWebpackPlugin = require('copy-webpack-plugin'); const htmlExtract = new ExtractTextPlugin('html', 'root.html'); -module.exports = { +const NPM_TARGET = process.env.npm_lifecycle_event; //eslint-disable-line no-process-env + +var DEV = false; +if (NPM_TARGET === 'run') { + DEV = true; +} + +var config = { entry: ['babel-polyfill', './root.jsx', 'root.html'], output: { path: 'dist', publicPath: '/static/', filename: 'bundle.js' }, - devtool: 'source-map', module: { loaders: [ { @@ -22,7 +28,7 @@ module.exports = { query: { presets: ['react', 'es2015-webpack', 'stage-0'], plugins: ['transform-runtime'], - cacheDirectory: true + cacheDirectory: DEV } }, { @@ -69,19 +75,8 @@ module.exports = { new CopyWebpackPlugin([ {from: 'images/emoji', to: 'emoji'} ]), - new webpack.optimize.UglifyJsPlugin({ - 'screw-ie8': true, - mangle: { - toplevel: false - }, - compress: { - warnings: false - }, - comments: false - }), - new webpack.optimize.AggressiveMergingPlugin(), new webpack.LoaderOptionsPlugin({ - minimize: true, + minimize: !DEV, debug: false }) ], @@ -96,3 +91,36 @@ module.exports = { ] } }; + +// Development mode configuration +if (DEV) { + config.devtool = 'eval-cheap-module-source-map'; +} + +// Production mode configuration +if (!DEV) { + config.devtool = 'source-map'; + config.plugins.push( + new webpack.optimize.UglifyJsPlugin({ + 'screw-ie8': true, + mangle: { + toplevel: false + }, + compress: { + warnings: false + }, + comments: false + }) + ); + config.plugins.push( + new webpack.optimize.AggressiveMergingPlugin() + ); + config.plugins.push( + new webpack.optimize.OccurrenceOrderPlugin(true) + ); + config.plugins.push( + new webpack.optimize.DedupePlugin() + ); +} + +module.exports = config; |