summaryrefslogtreecommitdiffstats
path: root/webapp/webpack.config.js
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-03-18 08:48:26 -0400
committerChristopher Speller <crspeller@gmail.com>2016-03-18 10:06:39 -0400
commit77ffdc699032f9a669caa7a640cfe734da49cc5a (patch)
tree9f9d5a7c6252a1277db4b8ace44786819dce2d47 /webapp/webpack.config.js
parent8d571ee498c97128bd797f8ac1cb4c3c995fb875 (diff)
downloadchat-77ffdc699032f9a669caa7a640cfe734da49cc5a.tar.gz
chat-77ffdc699032f9a669caa7a640cfe734da49cc5a.tar.bz2
chat-77ffdc699032f9a669caa7a640cfe734da49cc5a.zip
Creating sepearate dev and prod webpack builds. Enabled webpack watch mode. Updated to latest master webpack to fix bug in watch mode
Diffstat (limited to 'webapp/webpack.config.js')
-rw-r--r--webapp/webpack.config.js58
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;