config.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // https://umijs.org/config/
  2. import { defineConfig } from '@umijs/max'
  3. import defaultSettings from './defaultSettings'
  4. import proxy from './proxy'
  5. import routes from './routes'
  6. const { REACT_APP_ENV } = process.env
  7. const prodGzipList = ['js', 'css', 'html']
  8. export default defineConfig({
  9. plugins: [require.resolve('@umijs/plugins/dist/unocss')],
  10. npmClient: 'pnpm',
  11. hash: true,
  12. antd: {},
  13. model: {},
  14. moment2dayjs: {},
  15. request: {},
  16. initialState: {},
  17. access: {},
  18. dva: {},
  19. srcTranspiler: 'esbuild',
  20. mfsu: { esbuild: true },
  21. fastRefresh: true,
  22. unocss: {
  23. watch: ['src/pages/**/*.{jsx,tsx,less}', 'src/components/**/*.{jsx,tsx,less}'] // 添加其他包含 unocss 的 classname 的文件目录
  24. },
  25. // Fast Refresh 热更新
  26. theme: {},
  27. layout: {},
  28. // clickToComponent: {},
  29. locale: {
  30. default: 'zh-CN',
  31. antd: false,
  32. baseNavigator: false
  33. },
  34. define: { REACT_APP_ENV: REACT_APP_ENV || false },
  35. targets: { ie: 11 },
  36. routes,
  37. title: false,
  38. proxy: proxy[REACT_APP_ENV || 'dev'],
  39. manifest: { basePath: '/' },
  40. extraBabelPlugins: [
  41. ['babel-plugin-import', { libraryName: 'antd', libraryDirectory: 'es', style: true }, 'antd'],
  42. [
  43. 'babel-plugin-import',
  44. { libraryName: '@formily/antd', libraryDirectory: 'es', style: true },
  45. '@formily/antd'
  46. ]
  47. ]
  48. // chainWebpack(config, { env }) {
  49. // if (env === 'production') {
  50. // config.merge({
  51. // optimization: {
  52. // minimize: true,
  53. // splitChunks: {
  54. // chunks: 'all',
  55. // minSize: 30000,
  56. // minChunks: 2,
  57. // automaticNameDelimiter: '.',
  58. // cacheGroups: {
  59. // vendor: {
  60. // name: 'vendors',
  61. // test: ({ resource }) => /^.(?=react).$/.test(resource),
  62. // chunks: 'all',
  63. // priority: 20
  64. // }
  65. // }
  66. // }
  67. // }
  68. // })
  69. // config.plugin('compression-webpack-plugin').use(
  70. // new CompressionWebpackPlugin({
  71. // // filename: 文件名称,这里我们不设置,让它保持和未压缩的文件同一个名称
  72. // algorithm: 'gzip', // 指定生成gzip格式
  73. // test: new RegExp('\\.(' + prodGzipList.join('|') + ')$'), // 匹配哪些格式文件需要压缩
  74. // threshold: 10000, //对超过10k的数据进行压缩
  75. // minRatio: 0.6 // 压缩比例,值为0 ~ 1
  76. // })
  77. // )
  78. // }
  79. // }
  80. })