config.js 6.3 KB

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