config.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. {
  24. path: '/',
  25. component: './layouts/index',
  26. routes: [
  27. // dashboard
  28. { path: '/', redirect: '/dashboard/analysis' },
  29. { path: '/dashboard/analysis', component: './Dashboard/Analysis' },
  30. { path: '/dashboard/monitor', component: './Dashboard/Monitor' },
  31. { path: '/dashboard/workplace', component: './Dashboard/Workplace' },
  32. // forms
  33. { path: '/form/basic-form', component: './Forms/BasicForm' },
  34. {
  35. path: '/form/step-form',
  36. component: './Forms/StepForm',
  37. routes: [
  38. { path: '/form/step-form', redirect: '/form/step-form/info' },
  39. { path: '/form/step-form/info', component: './Forms/StepForm/Step1' },
  40. { path: '/form/step-form/confirm', component: './Forms/StepForm/Step2' },
  41. { path: '/form/step-form/result', component: './Forms/StepForm/Step3' },
  42. ],
  43. },
  44. { path: '/form/advanced-form', component: './Forms/AdvancedForm' },
  45. // list
  46. { path: '/list/table-list', component: './List/TableList' },
  47. { path: '/list/table-list', component: './List/TableList' },
  48. { path: '/list/basic-list', component: './List/BasicList' },
  49. { path: '/list/card-list', component: './List/CardList' },
  50. {
  51. path: '/list/search',
  52. component: './List/List',
  53. routes: [
  54. { path: '/list/search', redirect: '/list/search/projects' },
  55. { path: '/list/search/articles', component: './List/Articles' },
  56. { path: '/list/search/projects', component: './List/Projects' },
  57. { path: '/list/search/applications', component: './List/Applications' },
  58. ],
  59. },
  60. // profile
  61. { path: '/profile/basic', component: './Profile/BasicProfile' },
  62. { path: '/profile/advanced', component: './Profile/AdvancedProfile' },
  63. // result
  64. { path: '/result/success', component: './Result/Success' },
  65. { path: '/result/fail', component: './Result/Error' },
  66. // exception
  67. { path: '/exception/403', component: './Exception/403' },
  68. { path: '/exception/404', component: './Exception/404' },
  69. { path: '/exception/500', component: './Exception/500' },
  70. // acount
  71. {
  72. path: '/acount/center',
  73. component: './Account/Center/Center',
  74. routes: [
  75. { path: '/acount/center', redirect: '/acount/center/articles' },
  76. { path: '/acount/center/articles', component: './Account/Center/Articles' },
  77. { path: '/acount/center/applications', component: './Account/Center/Applications' },
  78. { path: '/acount/center/projects', component: './Account/Center/Projects' },
  79. ],
  80. },
  81. {
  82. path: '/acount/settings',
  83. component: './Account/Settings/Info',
  84. routes: [
  85. { path: '/acount/settings', redirect: '/acount/settings/base' },
  86. { path: '/acount/center/base', component: './Account/Settings/BaseView' },
  87. { path: '/acount/center/security', component: './Account/Settings/SecurityView' },
  88. { path: '/acount/center/binding', component: './Account/Settings/BindingView' },
  89. {
  90. path: '/acount/center/notification',
  91. component: './Account/Settings/NotificationView',
  92. },
  93. ],
  94. },
  95. ],
  96. },
  97. ],
  98. // https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
  99. theme: {
  100. // 'primary-color': '#10e99b',
  101. 'card-actions-background': '#f5f8fa',
  102. },
  103. // copy from old webpackrc.js
  104. // entry: 'src/index.js', // TODO remove
  105. extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
  106. env: {
  107. development: {
  108. extraBabelPlugins: ['dva-hmr'],
  109. },
  110. },
  111. externals: {
  112. '@antv/data-set': 'DataSet',
  113. bizcharts: 'BizCharts',
  114. rollbar: 'rollbar',
  115. },
  116. alias: {
  117. components: path.resolve(__dirname, '../src/components/'),
  118. utils: path.resolve(__dirname, '../src/utils/'),
  119. assets: path.resolve(__dirname, '../src/assets/'),
  120. common: path.resolve(__dirname, '../src/common/'),
  121. },
  122. ignoreMomentLocale: true,
  123. // theme: './theme.js',
  124. // html: { TODO remove
  125. // template: './index.ejs',
  126. // },
  127. publicPath: '/',
  128. // TODO check hash config
  129. // hash: true,
  130. lessLoaderOptions: {
  131. javascriptEnabled: true,
  132. },
  133. cssLoaderOptions: {
  134. modules: true,
  135. getLocalIdent: (context, localIdentName, localName) => {
  136. if (
  137. context.resourcePath.includes('node_modules') ||
  138. context.resourcePath.includes('ant.design.pro.less')
  139. ) {
  140. return localName;
  141. }
  142. const antdProPath = context.resourcePath.match(/src(.*)/)[1].replace('.less', '');
  143. const arr = antdProPath
  144. .split('/')
  145. .map(a => a.replace(/([A-Z])/g, '-$1'))
  146. .map(a => a.toLowerCase());
  147. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  148. },
  149. },
  150. };