config.prod.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // https://umijs.org/config/
  2. import { defineConfig } from 'umi'
  3. // import pagerouters from './config/routes'
  4. // import LodashModuleReplacementPlugin from 'lodash-webpack-plugin'
  5. // import CompressionPlugin from 'compression-webpack-plugin'
  6. export default defineConfig({
  7. outputPath: 'huanart',
  8. define: {
  9. GENERATE_SOURCEMAP: false,
  10. REACT_APP_LOCALE: 'zh-Hans',
  11. REACT_APP_APP_BASE_URL: 'https://www.huanart.com',
  12. // REACT_APP_MATERIAL_UPLOAD_URL: 'http://192.168.50.44:21022/api/Material/Upload',
  13. // REACT_APP_REMOTE_SERVICE_BASE_URL: 'http://192.168.50.44:21022',
  14. REACT_APP_MATERIAL_UPLOAD_URL: 'https://api.huanart.com/api/Material/Upload',
  15. REACT_APP_MATERIAL_ZIP_URL: 'https://api.huanart.com/api/Material/UploadZip',
  16. REACT_APP_REMOTE_SERVICE_BASE_URL: 'https://api.huanart.com',
  17. REACT_APP_WEIXIN_APPID: 'wx331ff3da84697769',
  18. REACT_APP_SITE_NAME: '欢画',
  19. REACT_APP_SITE_SHORT_NAME: '欢画',
  20. REACT_APP_SITE_THEME: 'dark',
  21. UMI_ENV: 'huanart',
  22. },
  23. theme: {
  24. 'primary-color': '#1890ff',
  25. },
  26. copy: [
  27. { from: 'src/assets/huanart', to: './' },
  28. { from: 'src/ico/favicon-huanart.ico', to: './favicon.ico' },
  29. ],
  30. chunks: ['vendors', 'umi'],
  31. chainWebpack(config) {
  32. config.module
  33. .rule('mjs$')
  34. .test(/.mjs$/)
  35. .include.add(/node_modules/)
  36. .end()
  37. .type('javascript/auto')
  38. config.output.filename('[name].bundle.[hash:8].js')
  39. config.output.chunkFilename('[chunkhash:8].chunk.js')
  40. // // config.plugin('dayjs').use(new AntdDayjsWebpackPlugin())
  41. // config.plugin('lodash-webpack-plugin').use(
  42. // new LodashModuleReplacementPlugin({
  43. // shorthands: true,
  44. // collections: true,
  45. // paths: true,
  46. // }),
  47. // )
  48. // if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'ado5') {
  49. // 开启gzip
  50. // config.plugin('compression-webpack-plugin').use(
  51. // //@ts-ignore
  52. // new CompressionPlugin({
  53. // test: /\.js$|\.html$|\.css$/, //匹配文件名
  54. // threshold: 10240, //对超过10k的数据压缩
  55. // deleteOriginalAssets: false, //不删除源文件
  56. // }),
  57. // )
  58. // config.merge({
  59. // optimization: {
  60. // splitChunks: {
  61. // chunks: 'all',
  62. // automaticNameDelimiter: '.',
  63. // name: true,
  64. // minSize: 30000,
  65. // minChunks: 1,
  66. // cacheGroups: {
  67. // vendors: {
  68. // name: 'vendors',
  69. // chunks: 'all',
  70. // test: /[\\/]node_modules[\\/]/,
  71. // priority: -12,
  72. // },
  73. // },
  74. // },
  75. // },
  76. // })
  77. config.merge({
  78. optimization: {
  79. splitChunks: {
  80. chunks: 'all',
  81. minSize: 30000,
  82. minChunks: 3,
  83. automaticNameDelimiter: '.',
  84. cacheGroups: {
  85. vendor: {
  86. name: 'vendors',
  87. test({ resource }: any) {
  88. return /[\\/]node_modules[\\/]/.test(resource)
  89. },
  90. priority: 10,
  91. },
  92. },
  93. },
  94. },
  95. })
  96. },
  97. plugins: [],
  98. })