config.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // https://umijs.org/config/
  2. import { defineConfig, utils } from 'umi';
  3. import defaultSettings from './defaultSettings';
  4. import proxy from './proxy';
  5. import webpackPlugin from './plugin.config';
  6. const { winPath } = utils; // 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, REACT_APP_ENV, GA_KEY } = process.env;
  9. export default defineConfig({
  10. hash: true,
  11. antd: {},
  12. analytics: GA_KEY
  13. ? {
  14. ga: GA_KEY,
  15. }
  16. : false,
  17. dva: {
  18. hmr: true,
  19. },
  20. locale: {
  21. // default zh-CN
  22. default: 'zh-CN',
  23. // default true, when it is true, will use `navigator.language` overwrite default
  24. antd: true,
  25. baseNavigator: true,
  26. },
  27. dynamicImport: {
  28. loading: '@/components/PageLoading/index',
  29. },
  30. targets: {
  31. ie: 11,
  32. },
  33. // umi routes: https://umijs.org/docs/routing
  34. routes: [
  35. {
  36. path: '/user',
  37. component: '../layouts/UserLayout',
  38. routes: [
  39. {
  40. name: 'login',
  41. path: '/user/login',
  42. component: './user/login',
  43. },
  44. ],
  45. },
  46. {
  47. path: '/',
  48. component: '../layouts/SecurityLayout',
  49. routes: [
  50. {
  51. path: '/',
  52. component: '../layouts/BasicLayout',
  53. authority: ['admin', 'user'],
  54. routes: [
  55. {
  56. path: '/',
  57. redirect: '/modelList',
  58. },
  59. // {
  60. // path: '/welcome',
  61. // name: 'welcome',
  62. // icon: 'smile',
  63. // component: './Welcome',
  64. // },
  65. // {
  66. // path: '/admin',
  67. // name: 'admin',
  68. // icon: 'crown',
  69. // component: './Admin',
  70. // authority: ['admin'],
  71. // routes: [
  72. // {
  73. // path: '/admin/sub-page',
  74. // name: 'sub-page',
  75. // icon: 'smile',
  76. // component: './Welcome',
  77. // authority: ['admin'],
  78. // },
  79. // ],
  80. // },
  81. // {
  82. // name: 'list.table-list',
  83. // icon: 'table',
  84. // path: '/list',
  85. // component: './ListTableList',
  86. // },
  87. {
  88. name: 'list.model-list',
  89. icon: 'smile',
  90. path: '/modelList',
  91. component: './ModelList',
  92. },
  93. {
  94. name: 'list.service-list',
  95. icon: 'smile',
  96. path: '/serviceList',
  97. component: './ServiceList',
  98. },
  99. {
  100. component: './404',
  101. },
  102. ],
  103. },
  104. {
  105. component: './404',
  106. },
  107. ],
  108. },
  109. {
  110. component: './404',
  111. },
  112. ],
  113. // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  114. theme: {
  115. // ...darkTheme,
  116. 'primary-color': defaultSettings.primaryColor,
  117. },
  118. define: {
  119. REACT_APP_ENV: REACT_APP_ENV || false,
  120. ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
  121. 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 专用环境变量,请不要在你的项目中使用它。
  122. },
  123. ignoreMomentLocale: true,
  124. lessLoader: {
  125. javascriptEnabled: true,
  126. },
  127. cssLoader: {
  128. modules: {
  129. getLocalIdent: (
  130. context: {
  131. resourcePath: string;
  132. },
  133. _: string,
  134. localName: string,
  135. ) => {
  136. if (
  137. context.resourcePath.includes('node_modules') ||
  138. context.resourcePath.includes('ant.design.pro.less') ||
  139. context.resourcePath.includes('global.less')
  140. ) {
  141. return localName;
  142. }
  143. const match = context.resourcePath.match(/src(.*)/);
  144. if (match && match[1]) {
  145. const antdProPath = match[1].replace('.less', '');
  146. const arr = winPath(antdProPath)
  147. .split('/')
  148. .map((a: string) => a.replace(/([A-Z])/g, '-$1'))
  149. .map((a: string) => a.toLowerCase());
  150. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  151. }
  152. return localName;
  153. },
  154. },
  155. },
  156. manifest: {
  157. basePath: '/',
  158. },
  159. proxy: proxy[REACT_APP_ENV || 'dev'],
  160. chainWebpack: webpackPlugin,
  161. });