|
|
@@ -31,6 +31,12 @@ export default defineConfig({
|
|
|
targets: {
|
|
|
ie: 11
|
|
|
},
|
|
|
+ terserOptions: {
|
|
|
+ compress: {
|
|
|
+ drop_console: REACT_APP_ENV === 'prod' ? true : false,
|
|
|
+ drop_debugger: REACT_APP_ENV === 'prod' ? true : false
|
|
|
+ }
|
|
|
+ },
|
|
|
// umi routes: https://umijs.org/docs/routing
|
|
|
routes,
|
|
|
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
|
|
|
@@ -46,6 +52,9 @@ export default defineConfig({
|
|
|
exportStatic: {},
|
|
|
esbuild: {},
|
|
|
fastRefresh: {},
|
|
|
+ nodeModulesTransform: {
|
|
|
+ type: 'none' // 提升编译速度加速,加速
|
|
|
+ },
|
|
|
extraBabelPlugins: [
|
|
|
'@babel/plugin-proposal-nullish-coalescing-operator',
|
|
|
'@babel/plugin-proposal-optional-chaining',
|
|
|
@@ -53,13 +62,44 @@ export default defineConfig({
|
|
|
'import',
|
|
|
{
|
|
|
libraryName: '@icon-park/react',
|
|
|
- libraryDirectory: 'es/all',
|
|
|
+ libraryDirectory: 'es/icons',
|
|
|
camel2DashComponentName: false
|
|
|
}
|
|
|
]
|
|
|
],
|
|
|
chainWebpack(config, { env }) {
|
|
|
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 (env === 'production') {
|
|
|
config.plugin('compression-webpack-plugin').use(
|
|
|
new CompressionWebpackPlugin({
|
|
|
@@ -71,5 +111,12 @@ export default defineConfig({
|
|
|
})
|
|
|
)
|
|
|
}
|
|
|
+ //过滤掉momnet的那些不使用的国际化文件
|
|
|
+ config
|
|
|
+ .plugin('replace')
|
|
|
+ .use(require('webpack').ContextReplacementPlugin)
|
|
|
+ .tap(() => {
|
|
|
+ return [/moment[/\\]locale$/, /zh-cn/]
|
|
|
+ })
|
|
|
}
|
|
|
})
|