|
|
@@ -67,40 +67,41 @@ export default defineConfig({
|
|
|
}
|
|
|
]
|
|
|
],
|
|
|
- chainWebpack(config, { env }) {
|
|
|
+ chainWebpack(config) {
|
|
|
config.plugin('windicss').use(windicss)
|
|
|
- config.merge({
|
|
|
- optimization: {
|
|
|
- minimize: true,
|
|
|
- splitChunks: {
|
|
|
- chunks: 'async',
|
|
|
- minSize: 30000,
|
|
|
- minChunks: 2,
|
|
|
- automaticNameDelimiter: '.',
|
|
|
- cacheGroups: {
|
|
|
- vendor: {
|
|
|
- name: 'vendors',
|
|
|
- test: /^.*node_modules[\\/](!lodash|antd).*$/,
|
|
|
- chunks: 'all',
|
|
|
- priority: 10
|
|
|
- },
|
|
|
- antd: {
|
|
|
- name: 'antd',
|
|
|
- test: /[\\/]node_modules[\\/]antd[\\/]/,
|
|
|
- chunks: 'all',
|
|
|
- priority: 9
|
|
|
- },
|
|
|
- lodash: {
|
|
|
- name: 'lodash',
|
|
|
- test: /[\\/]node_modules[\\/]lodash[\\/]/,
|
|
|
- chunks: 'all',
|
|
|
- priority: -2
|
|
|
+
|
|
|
+ if (REACT_APP_ENV === 'prod') {
|
|
|
+ config.merge({
|
|
|
+ optimization: {
|
|
|
+ minimize: true,
|
|
|
+ splitChunks: {
|
|
|
+ chunks: 'async',
|
|
|
+ minSize: 30000,
|
|
|
+ minChunks: 2,
|
|
|
+ automaticNameDelimiter: '.',
|
|
|
+ cacheGroups: {
|
|
|
+ vendor: {
|
|
|
+ name: 'vendors',
|
|
|
+ test: /^.*node_modules[\\/](!lodash|antd).*$/,
|
|
|
+ chunks: 'all',
|
|
|
+ priority: 10
|
|
|
+ },
|
|
|
+ antd: {
|
|
|
+ name: 'antd',
|
|
|
+ test: /[\\/]node_modules[\\/]antd[\\/]/,
|
|
|
+ chunks: 'all',
|
|
|
+ priority: 9
|
|
|
+ },
|
|
|
+ lodash: {
|
|
|
+ name: 'lodash',
|
|
|
+ test: /[\\/]node_modules[\\/]lodash[\\/]/,
|
|
|
+ chunks: 'all',
|
|
|
+ priority: -2
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- if (env === 'production') {
|
|
|
+ })
|
|
|
config.plugin('compression-webpack-plugin').use(
|
|
|
new CompressionWebpackPlugin({
|
|
|
// filename: 文件名称,这里我们不设置,让它保持和未压缩的文件同一个名称
|