Browse Source

release: 6.29.5

lanjianrong 4 năm trước cách đây
mục cha
commit
dee3661663
2 tập tin đã thay đổi với 37 bổ sung36 xóa
  1. 0 1
      .npmrc
  2. 37 35
      config/config.js

+ 0 - 1
.npmrc

@@ -1 +0,0 @@
-auto-install-peers=true

+ 37 - 35
config/config.js

@@ -1,11 +1,12 @@
 // https://umijs.org/config/
 
-const prodGzipList = ['js', 'css', 'html']
-
 import { defineConfig } from '@umijs/max'
 import defaultSettings from './defaultSettings'
 import proxy from './proxy'
 import routes from './routes'
+
+const CompressionPlugin = require('compression-webpack-plugin')
+const prodGzipList = ['js', 'css', 'html']
 const { REACT_APP_ENV } = process.env
 export default defineConfig({
   plugins: [require.resolve('@umijs/plugins/dist/unocss')],
@@ -73,37 +74,38 @@ export default defineConfig({
       : [
           'https://d2.smartcost.com.cn/cach/cld/react18.1.0/react.production.min.js',
           'https://d2.smartcost.com.cn/cach/cld/react18.1.0/react-dom.production.min.js'
-        ]
-  // chainWebpack(config, { env }) {
-  //   if (env === 'production') {
-  //     config.merge({
-  //       optimization: {
-  //         minimize: true,
-  //         splitChunks: {
-  //           chunks: 'all',
-  //           minSize: 30000,
-  //           minChunks: 2,
-  //           automaticNameDelimiter: '.',
-  //           cacheGroups: {
-  //             vendor: {
-  //               name: 'vendors',
-  //               test: ({ resource }) => /^.(?=react).$/.test(resource),
-  //               chunks: 'all',
-  //               priority: 20
-  //             }
-  //           }
-  //         }
-  //       }
-  //     })
-  //     config.plugin('compression-webpack-plugin').use(
-  //       new CompressionWebpackPlugin({
-  //         // filename: 文件名称,这里我们不设置,让它保持和未压缩的文件同一个名称
-  //         algorithm: 'gzip', // 指定生成gzip格式
-  //         test: new RegExp('\\.(' + prodGzipList.join('|') + ')$'), // 匹配哪些格式文件需要压缩
-  //         threshold: 10000, //对超过10k的数据进行压缩
-  //         minRatio: 0.6 // 压缩比例,值为0 ~ 1
-  //       })
-  //     )
-  //   }
-  // }
+        ],
+
+  chainWebpack(config, { env }) {
+    if (env === 'production') {
+      // config.merge({
+      //   optimization: {
+      //     minimize: true,
+      //     splitChunks: {
+      //       chunks: 'all',
+      //       minSize: 30000,
+      //       minChunks: 2,
+      //       automaticNameDelimiter: '.',
+      //       cacheGroups: {
+      //         vendor: {
+      //           name: 'vendors',
+      //           test: ({ resource }) => /[\\/]node_modules[\\/]/.test(resource),
+      //           chunks: 'all',
+      //           priority: 20
+      //         }
+      //       }
+      //     }
+      //   }
+      // })
+      config.plugin('compression-webpack-plugin').use(
+        new CompressionPlugin({
+          // filename: 文件名称,这里我们不设置,让它保持和未压缩的文件同一个名称
+          algorithm: 'gzip', // 指定生成gzip格式
+          test: new RegExp('\\.(' + prodGzipList.join('|') + ')$'), // 匹配哪些格式文件需要压缩
+          threshold: 10000, //对超过10k的数据进行压缩
+          minRatio: 0.6 // 压缩比例,值为0 ~ 1
+        })
+      )
+    }
+  }
 })