123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import defaultSettings from './defaultSettings'; // https://umijs.org/config/
  2. import routes from './routes';
  3. import slash from 'slash2';
  4. import webpackPlugin from './plugin.config';
  5. const { pwa, primaryColor } = defaultSettings; // preview.pro.ant.design only do not use in your production ;
  6. // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
  7. const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env;
  8. const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site';
  9. const plugins = [
  10. [
  11. 'umi-plugin-react',
  12. {
  13. antd: true,
  14. dva: {
  15. hmr: true,
  16. },
  17. locale: {
  18. // default false
  19. enable: true,
  20. // default zh-CN
  21. default: 'zh-CN',
  22. // default true, when it is true, will use `navigator.language` overwrite default
  23. baseNavigator: true,
  24. },
  25. dynamicImport: {
  26. loadingComponent: './components/PageLoading/index',
  27. webpackChunkName: true,
  28. level: 3,
  29. },
  30. pwa: pwa
  31. ? {
  32. workboxPluginMode: 'InjectManifest',
  33. workboxOptions: {
  34. importWorkboxFrom: 'local',
  35. },
  36. }
  37. : false, // default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665
  38. // dll features https://webpack.js.org/plugins/dll-plugin/
  39. // dll: {
  40. // include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  41. // exclude: ['@babel/runtime', 'netlify-lambda'],
  42. // },
  43. },
  44. ],
  45. [
  46. 'umi-plugin-pro-block',
  47. {
  48. moveMock: false,
  49. moveService: false,
  50. modifyRequest: true,
  51. autoAddMenu: true,
  52. },
  53. ],
  54. ]; // 针对 preview.pro.ant.design 的 GA 统计代码
  55. if (isAntDesignProPreview) {
  56. plugins.push([
  57. 'umi-plugin-ga',
  58. {
  59. code: 'UA-72788897-6',
  60. },
  61. ]);
  62. plugins.push([
  63. 'umi-plugin-pro',
  64. {
  65. serverUrl: 'https://ant-design-pro.netlify.com',
  66. },
  67. ]);
  68. }
  69. export default {
  70. plugins,
  71. block: {
  72. // 国内用户可以使用码云
  73. // defaultGitUrl: 'https://gitee.com/ant-design/pro-blocks',
  74. defaultGitUrl: 'https://github.com/ant-design/pro-blocks',
  75. },
  76. hash: true,
  77. targets: {
  78. ie: 11,
  79. },
  80. publicPath: './',
  81. // publicPath: 'https://njcjweb.oss-accelerate.aliyuncs.com/channel/',
  82. history: 'hash',
  83. treeShaking: true,
  84. devtool: isAntDesignProPreview ? 'source-map' : false,
  85. // umi routes: https://umijs.org/zh/guide/router.html
  86. routes,
  87. // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  88. theme: {
  89. 'primary-color': primaryColor,
  90. },
  91. define: {
  92. ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
  93. ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
  94. },
  95. ignoreMomentLocale: true,
  96. lessLoaderOptions: {
  97. javascriptEnabled: true,
  98. },
  99. disableRedirectHoist: true,
  100. cssLoaderOptions: {
  101. modules: true,
  102. getLocalIdent: (context, _, localName) => {
  103. if (
  104. context.resourcePath.includes('node_modules') ||
  105. context.resourcePath.includes('ant.design.pro.less') ||
  106. context.resourcePath.includes('global.less')
  107. ) {
  108. return localName;
  109. }
  110. const match = context.resourcePath.match(/src(.*)/);
  111. if (match && match[1]) {
  112. const antdProPath = match[1].replace('.less', '');
  113. const arr = slash(antdProPath)
  114. .split('/')
  115. .map(a => a.replace(/([A-Z])/g, '-$1'))
  116. .map(a => a.toLowerCase());
  117. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  118. }
  119. return localName;
  120. },
  121. },
  122. manifest: {
  123. basePath: '/',
  124. },
  125. chainWebpack: webpackPlugin,
  126. proxy: {
  127. '/api': {
  128. target: 'https://dev.fangdeal.cn',
  129. // target: 'http://192.168.0.153:8080/',
  130. changeOrigin: true,
  131. // pathRewrite: { '^/server': '' },
  132. },
  133. },
  134. };