|
@@ -1,17 +1,17 @@
|
|
|
// 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'
|
|
|
+import { defineConfig } from '@umijs/max'
|
|
|
+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')],
|
|
|
npmClient: 'pnpm',
|
|
|
hash: true,
|
|
|
- antd: { import: true },
|
|
|
+ antd: {},
|
|
|
model: {},
|
|
|
moment2dayjs: {},
|
|
|
request: {},
|
|
@@ -27,19 +27,18 @@ export default defineConfig({
|
|
|
// Fast Refresh 热更新
|
|
|
theme: { 'primary-color': '#886ab5' },
|
|
|
layout: {},
|
|
|
+ deadCode: {}, // 检测未使用的文件和导出,仅在 build 阶段开启
|
|
|
locale: {
|
|
|
default: 'zh-CN',
|
|
|
antd: false,
|
|
|
baseNavigator: false
|
|
|
},
|
|
|
define: { REACT_APP_ENV: REACT_APP_ENV || false },
|
|
|
- targets: { ie: 11 },
|
|
|
routes,
|
|
|
title: false,
|
|
|
proxy: proxy[REACT_APP_ENV || 'dev'],
|
|
|
manifest: { basePath: '/' },
|
|
|
extraBabelPlugins: [
|
|
|
- ['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }, 'antd'],
|
|
|
[
|
|
|
'import',
|
|
|
{
|
|
@@ -48,42 +47,30 @@ export default defineConfig({
|
|
|
camel2DashComponentName: false
|
|
|
},
|
|
|
'@icon-park/react'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'import',
|
|
|
+ {
|
|
|
+ libraryName: 'antd',
|
|
|
+ libraryDirectory: 'es',
|
|
|
+ style: 'less'
|
|
|
+ },
|
|
|
+ 'antd'
|
|
|
]
|
|
|
],
|
|
|
- externals: {
|
|
|
+ externals: REACT_APP_ENV !== 'dev' && {
|
|
|
react: 'React',
|
|
|
'react-dom': 'ReactDOM'
|
|
|
},
|
|
|
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
|
|
|
- })
|
|
|
- )
|
|
|
- }
|
|
|
+ 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
|
|
|
+ })
|
|
|
+ )
|
|
|
}
|
|
|
})
|