config.laitin.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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: 'laitin',
  8. define: {
  9. GENERATE_SOURCEMAP: false,
  10. REACT_APP_LOCALE: 'zh-Hans',
  11. REACT_APP_APP_BASE_URL: 'https://www.laitin-art.com',
  12. REACT_APP_MATERIAL_UPLOAD_URL: 'https://api.laitin-art.com/api/Material/Upload',
  13. REACT_APP_MATERIAL_ZIP_URL: 'https://api.laitin-art.com/api/Material/UploadZip',
  14. REACT_APP_REMOTE_SERVICE_BASE_URL: 'https://api.laitin-art.com',
  15. REACT_APP_WEIXIN_APPID: 'wx9788037ac9f7521e',
  16. REACT_APP_SITE_NAME: '高端装饰画图库',
  17. REACT_APP_SITE_SHORT_NAME: '高端装饰画图库',
  18. REACT_APP_SITE_THEME: 'light',
  19. UMI_ENV: 'laitin',
  20. },
  21. theme: {
  22. 'primary-color': '#1890ff',
  23. },
  24. chunks: ['vendors', 'umi'],
  25. copy: [
  26. { from: 'src/assets/laitin', to: './' },
  27. ],
  28. chainWebpack(config) {
  29. config.module
  30. .rule('mjs$')
  31. .test(/.mjs$/)
  32. .include.add(/node_modules/)
  33. .end()
  34. .type('javascript/auto')
  35. config.output.filename('[name].bundle.[hash:8].js')
  36. config.output.chunkFilename('[chunkhash:8].chunk.js')
  37. // // config.plugin('dayjs').use(new AntdDayjsWebpackPlugin())
  38. // config.plugin('lodash-webpack-plugin').use(
  39. // new LodashModuleReplacementPlugin({
  40. // shorthands: true,
  41. // collections: true,
  42. // paths: true,
  43. // }),
  44. // )
  45. // if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'ado5') {
  46. // 开启gzip
  47. // config.plugin('compression-webpack-plugin').use(
  48. // //@ts-ignore
  49. // new CompressionPlugin({
  50. // test: /\.js$|\.html$|\.css$/, //匹配文件名
  51. // threshold: 10240, //对超过10k的数据压缩
  52. // deleteOriginalAssets: false, //不删除源文件
  53. // }),
  54. // )
  55. config.merge({
  56. optimization: {
  57. splitChunks: {
  58. chunks: 'all',
  59. minSize: 30000,
  60. minChunks: 3,
  61. automaticNameDelimiter: '.',
  62. cacheGroups: {
  63. vendor: {
  64. name: 'vendors',
  65. test({ resource }: any) {
  66. return /[\\/]node_modules[\\/]/.test(resource)
  67. },
  68. priority: 10,
  69. },
  70. },
  71. },
  72. },
  73. })
  74. },
  75. plugins: [],
  76. })