知与行后台管理端

config.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. history: 'hash',
  83. devtool: isAntDesignProPreview ? 'source-map' : false,
  84. // umi routes: https://umijs.org/zh/guide/router.html
  85. routes,
  86. // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  87. theme: {
  88. 'primary-color': primaryColor,
  89. 'btn-primary-bg': '#EF273A',
  90. 'table-row-hover-bg': '#eee',
  91. 'btn-danger-bg': '#FF7E48',
  92. 'radio-button-hover-color': '#FF7E48',
  93. 'radio-button-active-color': 'red',
  94. },
  95. define: {
  96. ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
  97. 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 专用环境变量,请不要在你的项目中使用它。
  98. },
  99. ignoreMomentLocale: true,
  100. lessLoaderOptions: {
  101. javascriptEnabled: true,
  102. },
  103. disableRedirectHoist: true,
  104. cssLoaderOptions: {
  105. modules: true,
  106. getLocalIdent: (context, _, localName) => {
  107. if (
  108. context.resourcePath.includes('node_modules') ||
  109. context.resourcePath.includes('ant.design.pro.less') ||
  110. context.resourcePath.includes('global.less')
  111. ) {
  112. return localName;
  113. }
  114. const match = context.resourcePath.match(/src(.*)/);
  115. if (match && match[1]) {
  116. const antdProPath = match[1].replace('.less', '');
  117. const arr = slash(antdProPath)
  118. .split('/')
  119. .map(a => a.replace(/([A-Z])/g, '-$1'))
  120. .map(a => a.toLowerCase());
  121. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  122. }
  123. return localName;
  124. },
  125. },
  126. manifest: {
  127. basePath: '/',
  128. },
  129. chainWebpack: webpackPlugin,
  130. proxy: {
  131. ...proxy,
  132. '/gaode_amap': { // 高德地图
  133. // target: 'http://192.168.0.11:8080/',
  134. target: 'https://restapi.amap.com/v3/',
  135. changeOrigin: true,
  136. pathRewrite: { '^/gaode_amap': '' },
  137. },
  138. },
  139. };