Browse Source

文件分离优化

wangziqian 5 years ago
parent
commit
3c9682e3b9
1 changed files with 31 additions and 12 deletions
  1. 31 12
      vue.config.js

+ 31 - 12
vue.config.js

@@ -109,26 +109,45 @@ module.exports = {
             .optimization.splitChunks({
               chunks: 'all',
               cacheGroups: {
-                libs: {
-                  name: 'chunk-libs',
+                vendors: {
+                  name: 'chunk-vendors',
                   test: /[\\/]node_modules[\\/]/,
-                  priority: -10,
-                  chunks: 'initial' // only package third parties that are initially dependent
+                  chunks: 'initial',
+                  priority: 2,
+                  reuseExistingChunk: true,
+                  enforce: true
                 },
                 elementUI: {
                   name: 'chunk-elementUI', // split elementUI into a single package
-                  priority: 10, // the weight needs to be larger than libs and app or it will be packaged into libs or app
-                  test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
+                  priority: 3, // the weight needs to be larger than libs and app or it will be packaged into libs or app
+                  test: /[\\/]node_modules[\\/]element-ui[\\/]/, // in order to adapt to cnpm
+                  chunks: 'initial',
+                  reuseExistingChunk: true,
+                  enforce: true
+                },
+                antDesignVue: {
+                  name: 'chunk-ant-design-vue',
+                  test: /[\\/]node_modules[\\/]ant-design-vue[\\/]/,
+                  chunks: 'initial',
+                  priority: 3,
+                  reuseExistingChunk: true,
+                  enforce: true
                 },
                 echarts: {
-                  name: 'chunk-echarts', // split elementUI into a single package
-                  priority: 9, // the weight needs to be larger than libs and app or it will be packaged into libs or app
-                  test: /[\\/]node_modules[\\/]_?echarts(.*)/ // in order to adapt to cnpm
+                  name: 'chunk-echarts',
+                  test: /[\\/]node_modules[\\/]echarts[\\/]/,
+                  chunks: 'initial',
+                  priority: 3,
+                  reuseExistingChunk: true,
+                  enforce: true
                 },
                 tinymce: {
-                  name: 'chunk-tinymce', // split elementUI into a single package
-                  priority: 8, // the weight needs to be larger than libs and app or it will be packaged into libs or app
-                  test: /[\\/]node_modules[\\/]_?tinymce(.*)/ // in order to adapt to cnpm
+                  name: 'chunk-tinymce',
+                  test: /[\\/]node_modules[\\/]tinymce[\\/]/,
+                  chunks: 'initial',
+                  priority: 3,
+                  reuseExistingChunk: true,
+                  enforce: true
                 },
                 commons: {
                   name: 'chunk-commons',