瀏覽代碼

Add UglifyJS plugin to webpack.config for production client bundle

Vladimir Kutepov 9 年之前
父節點
當前提交
35e9bf0994
共有 1 個文件被更改,包括 12 次插入4 次删除
  1. 12 4
      tools/config.js

+ 12 - 4
tools/config.js

@@ -97,10 +97,18 @@ const appConfig = merge({}, config, {
   output: {
     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