config.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* eslint-disable react/destructuring-assignment */
  2. // https://umijs.org/config/
  3. const path = require('path');
  4. // const pageRoutes = require('../_routes');
  5. export default {
  6. // add for transfer to umi
  7. plugins: [
  8. 'umi-plugin-dva',
  9. // TODO 决定是否使用约定路由,如果使用配置路由那么 umi-plugin-routes 可以去掉了
  10. // [
  11. // 'umi-plugin-routes',
  12. // {
  13. // exclude: [/\.test\.js/],
  14. // update(routes) {
  15. // return [...pageRoutes, ...routes];
  16. // },
  17. // },
  18. // ],
  19. ],
  20. disableServiceWorker: true,
  21. // 路由配置
  22. routes: [
  23. // user
  24. {
  25. path: '/user',
  26. component: './layouts/UserLayout',
  27. routes: [
  28. { path: '/user', redirect: '/user/login' },
  29. { path: '/user/login', component: '/User/Login' },
  30. { path: '/user/register', component: './User/Register' },
  31. { path: '/user/register-result', component: './User/RegisterResult' },
  32. ],
  33. },
  34. // app
  35. {
  36. path: '/',
  37. component: './layouts/LoadingPage',
  38. routes: [
  39. // dashboard
  40. { path: '/', redirect: '/dashboard/analysis' },
  41. { path: '/dashboard/analysis', component: './Dashboard/Analysis' },
  42. { path: '/dashboard/monitor', component: './Dashboard/Monitor' },
  43. { path: '/dashboard/workplace', component: './Dashboard/Workplace' },
  44. // forms
  45. { path: '/form/basic-form', component: './Forms/BasicForm' },
  46. {
  47. path: '/form/step-form',
  48. component: './Forms/StepForm',
  49. routes: [
  50. { path: '/form/step-form', redirect: '/form/step-form/info' },
  51. { path: '/form/step-form/info', component: './Forms/StepForm/Step1' },
  52. { path: '/form/step-form/confirm', component: './Forms/StepForm/Step2' },
  53. { path: '/form/step-form/result', component: './Forms/StepForm/Step3' },
  54. ],
  55. },
  56. { path: '/form/advanced-form', component: './Forms/AdvancedForm' },
  57. // list
  58. { path: '/list/table-list', component: './List/TableList' },
  59. { path: '/list/table-list', component: './List/TableList' },
  60. { path: '/list/basic-list', component: './List/BasicList' },
  61. { path: '/list/card-list', component: './List/CardList' },
  62. {
  63. path: '/list/search',
  64. component: './List/List',
  65. routes: [
  66. { path: '/list/search', redirect: '/list/search/projects' },
  67. { path: '/list/search/articles', component: './List/Articles' },
  68. { path: '/list/search/projects', component: './List/Projects' },
  69. { path: '/list/search/applications', component: './List/Applications' },
  70. ],
  71. },
  72. // profile
  73. { path: '/profile/basic', component: './Profile/BasicProfile' },
  74. { path: '/profile/advanced', component: './Profile/AdvancedProfile' },
  75. // result
  76. { path: '/result/success', component: './Result/Success' },
  77. { path: '/result/fail', component: './Result/Error' },
  78. // exception
  79. { path: '/exception/403', component: './Exception/403' },
  80. { path: '/exception/404', component: './Exception/404' },
  81. { path: '/exception/500', component: './Exception/500' },
  82. // account
  83. {
  84. path: '/account/center',
  85. component: './Account/Center/Center',
  86. routes: [
  87. { path: '/account/center', redirect: '/account/center/articles' },
  88. { path: '/account/center/articles', component: './Account/Center/Articles' },
  89. { path: '/account/center/applications', component: './Account/Center/Applications' },
  90. { path: '/account/center/projects', component: './Account/Center/Projects' },
  91. ],
  92. },
  93. {
  94. path: '/account/settings',
  95. component: './Account/Settings/Info',
  96. routes: [
  97. { path: '/account/settings', redirect: '/account/settings/base' },
  98. { path: '/account/settings/base', component: './Account/Settings/BaseView' },
  99. { path: '/account/settings/security', component: './Account/Settings/SecurityView' },
  100. { path: '/account/settings/binding', component: './Account/Settings/BindingView' },
  101. {
  102. path: '/account/settings/notification',
  103. component: './Account/Settings/NotificationView',
  104. },
  105. ],
  106. },
  107. ],
  108. },
  109. ],
  110. // https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
  111. theme: {
  112. // 'primary-color': '#10e99b',
  113. 'card-actions-background': '#f5f8fa',
  114. },
  115. // copy from old webpackrc.js
  116. // entry: 'src/index.js', // TODO remove
  117. extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
  118. env: {
  119. development: {
  120. extraBabelPlugins: ['dva-hmr'],
  121. },
  122. },
  123. externals: {
  124. '@antv/data-set': 'DataSet',
  125. bizcharts: 'BizCharts',
  126. rollbar: 'rollbar',
  127. },
  128. alias: {
  129. components: path.resolve(__dirname, '../src/components/'),
  130. utils: path.resolve(__dirname, '../src/utils/'),
  131. assets: path.resolve(__dirname, '../src/assets/'),
  132. common: path.resolve(__dirname, '../src/common/'),
  133. },
  134. ignoreMomentLocale: true,
  135. // theme: './theme.js',
  136. // html: { TODO remove
  137. // template: './index.ejs',
  138. // },
  139. publicPath: '/',
  140. // TODO check hash config
  141. // hash: true,
  142. lessLoaderOptions: {
  143. javascriptEnabled: true,
  144. },
  145. cssLoaderOptions: {
  146. modules: true,
  147. getLocalIdent: (context, localIdentName, localName) => {
  148. if (
  149. context.resourcePath.includes('node_modules') ||
  150. context.resourcePath.includes('ant.design.pro.less')
  151. ) {
  152. return localName;
  153. }
  154. const antdProPath = context.resourcePath.match(/src(.*)/)[1].replace('.less', '');
  155. const arr = antdProPath
  156. .split('/')
  157. .map(a => a.replace(/([A-Z])/g, '-$1'))
  158. .map(a => a.toLowerCase());
  159. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  160. },
  161. },
  162. };