知与行后台管理端

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