123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- // https://umijs.org/config/
- import defaultSettings from './defaultSettings'
- import proxy from './proxy'
- import routes from './routes'
- import { defineConfig } from '@umijs/max'
- const CompressionWebpackPlugin = require('compression-webpack-plugin')
- const { REACT_APP_ENV } = process.env
- const prodGzipList = ['js', 'css', 'html']
- export default defineConfig({
- plugins: [require.resolve('@umijs/plugins/dist/unocss')],
- npmClient: 'pnpm',
- hash: true,
- antd: {},
- model: {},
- moment2dayjs: {},
- request: {},
- initialState: {},
- access: {},
- dva: {},
- srcTranspiler: 'esbuild',
- mfsu: {},
- fastRefresh: true,
- unocss: {
- watch: ['src/{pages,components}/**/*.{jsx,tsx,less}'] // 添加其他包含 unocss 的 classname 的文件目录
- },
- // Fast Refresh 热更新
- theme: {},
- layout: {},
- // clickToComponent: {},
- 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: [
- ['babel-plugin-import', { libraryName: 'antd', libraryDirectory: 'es', style: true }, 'antd'],
- [
- 'babel-plugin-import',
- { libraryName: '@formily/antd', libraryDirectory: 'es', style: true },
- '@formily/antd'
- ]
- ],
- chainWebpack(config, { env }) {
- if (env === 'production') {
- 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
- })
- )
- }
- }
- })
|