config.ts 2.3 KB

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