liting2017 6 years ago
parent
commit
294c1d7a70
1 changed files with 18 additions and 2 deletions
  1. 18 2
      webpack.config.js

+ 18 - 2
webpack.config.js

@@ -17,9 +17,25 @@ let isDev = isWatch || argv.env.deploy == 'dev';
 
 module.exports = (function () {
     let plugins = [
+        // new webpack.optimize.CommonsChunkPlugin({
+        //     name: 'vendors',
+        //     minChunks: 4
+        // }),
+        new webpack.optimize.CommonsChunkPlugin({
+            name: 'vendor',
+            minChunks: function (module) {
+              return (
+                module.resource &&
+                /\.js$/.test(module.resource) &&
+                module.resource.indexOf(
+                  path.join(__dirname, '../node_modules')
+                ) === 0
+              )
+            }
+        }),
         new webpack.optimize.CommonsChunkPlugin({
             name: 'vendors',
-            minChunks: 4
+            chunks: ['vendor']
         }),
         new ExtractTextPlugin({
             filename: "[name].css",
@@ -41,7 +57,7 @@ module.exports = (function () {
             title: '搜索页',
             filename: 'html/index.html',
             template: './template/search.html',
-            chunks: ['vendors','search']
+            chunks: ['vendors','search'],
         }),
         // new HtmlWebpackPlugin({
         //     title: '支付跳转页面',