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