.umirc.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // ref: https://umijs.org/config/
  2. import proxyMap from "./src/conf/proxyMap";
  3. // const proxyMap = require('./proxyMap')
  4. export default {
  5. treeShaking: true,
  6. // chainWebpack(config) {
  7. // // config.plugin('moment-locales').use(momentLocalesWebpackPlugin, [{
  8. // // localesToKeep: ['zh-cn'],
  9. // // }])
  10. // config.merge({
  11. // optimization: {
  12. // minimize: true,
  13. // splitChunks: {
  14. // chunks: 'all',
  15. // minSize: 30000,
  16. // minChunks: 3,
  17. // automaticNameDelimiter: '.',
  18. // cacheGroups: {
  19. // vendors: {
  20. // name: 'common',
  21. // test({ resource }) {
  22. // return /[\\/]node_modules[\\/]/.test(resource);
  23. // },
  24. // priority: 10,
  25. // },
  26. // },
  27. // },
  28. // }
  29. // })
  30. // },
  31. plugins: [
  32. // ref: https://umijs.org/plugin/umi-plugin-react.html
  33. [
  34. "umi-plugin-react",
  35. {
  36. antd: true,
  37. dva: true,
  38. dynamicImport: { webpackChunkName: true },
  39. title: "后端应用后台",
  40. dll: true,
  41. routes: {
  42. exclude: [
  43. /models\//,
  44. /services\//,
  45. /model\.(t|j)sx?$/,
  46. /service\.(t|j)sx?$/,
  47. /components\//,
  48. ],
  49. },
  50. },
  51. ],
  52. ],
  53. proxy: (function () {
  54. const proxyArr = Object.keys(proxyMap).map((apiPrefix) => ({
  55. [apiPrefix]: {
  56. target: proxyMap[apiPrefix],
  57. changeOrigin: true,
  58. pathRewrite: { [`^${apiPrefix}`]: "" },
  59. cookieDomainRewrite: "",
  60. },
  61. }));
  62. const proxy = proxyArr.reduce((acc, item) => ({ ...acc, ...item }), {});
  63. return proxy;
  64. })(),
  65. };