| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- // https://umijs.org/config/
- const CompressionWebpackPlugin = require('compression-webpack-plugin')
- const prodGzipList = ['js', 'css']
- import { defineConfig } from 'umi'
- import defaultSettings from './defaultSettings'
- import proxy from './proxy'
- import routes from './routes'
- import windicss from 'windicss-webpack-plugin/dist/index'
- const { REACT_APP_ENV } = process.env
- export default defineConfig({
- hash: true,
- antd: {},
- dva: {
- hmr: true
- },
- history: {
- type: 'browser'
- },
- locale: {
- // default zh-CN
- default: 'zh-CN',
- antd: false,
- // default true, when it is true, will use `navigator.language` overwrite default
- baseNavigator: false
- },
- dynamicImport: {
- loading: '@/components/PageLoading/index'
- },
- targets: {
- ie: 11
- },
- // umi routes: https://umijs.org/docs/routing
- routes,
- // Theme for antd: https://ant.design/docs/react/customize-theme-cn
- theme: {
- 'primary-color': defaultSettings.primaryColor
- },
- title: false,
- ignoreMomentLocale: true,
- proxy: proxy[REACT_APP_ENV || 'dev'],
- manifest: {
- basePath: '/'
- },
- exportStatic: {},
- esbuild: {},
- fastRefresh: {},
- extraBabelPlugins: [
- '@babel/plugin-proposal-nullish-coalescing-operator',
- '@babel/plugin-proposal-optional-chaining',
- [
- 'import',
- {
- libraryName: '@icon-park/react',
- libraryDirectory: 'es/all',
- camel2DashComponentName: false
- }
- ]
- ],
- chainWebpack(config, { env }) {
- config.plugin('windicss').use(windicss)
- if (env === 'production') {
- config.plugin('compression-webpack-plugin').use(
- new CompressionWebpackPlugin({
- // filename: 文件名称,这里我们不设置,让它保持和未压缩的文件同一个名称
- algorithm: 'gzip', // 指定生成gzip格式
- test: new RegExp('\\.(' + prodGzipList.join('|') + ')$'), // 匹配哪些格式文件需要压缩
- threshold: 1024, //对超过10k的数据进行压缩
- minRatio: 0.6 // 压缩比例,值为0 ~ 1
- })
- )
- }
- }
- })
|