Browse Source

Add UglifyJS plugin to webpack.config for production client bundle

Vladimir Kutepov 9 years ago
parent
commit
35e9bf0994
1 changed files with 12 additions and 4 deletions
  1. 12 4
      tools/config.js

+ 12 - 4
tools/config.js

@@ -97,10 +97,18 @@ const appConfig = merge({}, config, {
   output: {
   output: {
     filename: 'app.js'
     filename: 'app.js'
   },
   },
-  plugins: config.plugins.concat(WATCH ? [
-    new webpack.HotModuleReplacementPlugin(),
-    new webpack.NoErrorsPlugin()
-  ] : [])
+  plugins: [
+    ...config.plugins,
+    ...(DEBUG ? [] : [
+      new webpack.optimize.DedupePlugin(),
+      new webpack.optimize.UglifyJsPlugin({compress: {warnings: VERBOSE}}),
+      new webpack.optimize.AggressiveMergingPlugin()
+    ]),
+    ...(WATCH ? [
+      new webpack.HotModuleReplacementPlugin(),
+      new webpack.NoErrorsPlugin()
+    ] : [])
+  ]
 });
 });
 
 
 // Configuration for server-side pre-rendering bundle
 // Configuration for server-side pre-rendering bundle