config.js 6.2 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. // account
  90. {
  91. path: '/account/center',
  92. component: './Account/Center/Center',
  93. routes: [
  94. { path: '/account/center', redirect: '/account/center/articles' },
  95. { path: '/account/center/articles', component: './Account/Center/Articles' },
  96. { path: '/account/center/applications', component: './Account/Center/Applications' },
  97. { path: '/account/center/projects', component: './Account/Center/Projects' },
  98. ],
  99. },
  100. {
  101. path: '/account/settings',
  102. component: './Account/Settings/Info',
  103. routes: [
  104. { path: '/account/settings', redirect: '/account/settings/base' },
  105. { path: '/account/settings/base', component: './Account/Settings/BaseView' },
  106. { path: '/account/settings/security', component: './Account/Settings/SecurityView' },
  107. { path: '/account/settings/binding', component: './Account/Settings/BindingView' },
  108. {
  109. path: '/account/settings/notification',
  110. component: './Account/Settings/NotificationView',
  111. },
  112. ],
  113. },
  114. ],
  115. },
  116. ],
  117. // https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
  118. theme: {
  119. // 'primary-color': '#10e99b',
  120. 'card-actions-background': '#f5f8fa',
  121. },
  122. // copy from old webpackrc.js
  123. // entry: 'src/index.js', // TODO remove
  124. extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
  125. env: {
  126. development: {
  127. extraBabelPlugins: ['dva-hmr'],
  128. },
  129. },
  130. externals: {
  131. '@antv/data-set': 'DataSet',
  132. bizcharts: 'BizCharts',
  133. rollbar: 'rollbar',
  134. },
  135. alias: {
  136. components: path.resolve(__dirname, '../src/components/'),
  137. utils: path.resolve(__dirname, '../src/utils/'),
  138. assets: path.resolve(__dirname, '../src/assets/'),
  139. common: path.resolve(__dirname, '../src/common/'),
  140. },
  141. ignoreMomentLocale: true,
  142. // theme: './theme.js',
  143. // html: { TODO remove
  144. // template: './index.ejs',
  145. // },
  146. publicPath: '/',
  147. // TODO check hash config
  148. // hash: true,
  149. lessLoaderOptions: {
  150. javascriptEnabled: true,
  151. },
  152. cssLoaderOptions: {
  153. modules: true,
  154. getLocalIdent: (context, localIdentName, localName) => {
  155. if (
  156. context.resourcePath.includes('node_modules') ||
  157. context.resourcePath.includes('ant.design.pro.less')
  158. ) {
  159. return localName;
  160. }
  161. const antdProPath = context.resourcePath.match(/src(.*)/)[1].replace('.less', '');
  162. const arr = antdProPath
  163. .split('/')
  164. .map(a => a.replace(/([A-Z])/g, '-$1'))
  165. .map(a => a.toLowerCase());
  166. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  167. },
  168. },
  169. disableFastClick: true,
  170. };