config.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* eslint-disable react/destructuring-assignment */
  2. // https://umijs.org/config/
  3. const path = require('path');
  4. const pageRoutes = require('../src/pages/_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. // TODO ./src/pages 太冗余了
  23. // routes: [{
  24. // path: '/',
  25. // component: './src/layouts/BasicLayout',
  26. // indexRoute: { redirect: '/dashboard/analysis' },
  27. // childRoutes: [
  28. // // dashboard
  29. // { path: 'dashboard/analysis', component: './src/pages/Dashboard/Analysis' },
  30. // { path: 'dashboard/monitor', component: './src/pages/Dashboard/Monitor' },
  31. // { path: 'dashboard/workplace', component: './src/pages/Dashboard/Workplace' },
  32. // // forms
  33. // { path: 'form/basic-form', component: './src/pages/Forms/BasicForm' },
  34. // {
  35. // path: 'form/step-form',
  36. // component: './src/pages/Forms/StepForm',
  37. // indexRoute: { redirect: '/form/step-form/info' },
  38. // childRoutes: [
  39. // { path: 'info', component: './src/pages/Forms/StepForm/Step1' },
  40. // { path: 'confirm', component: './src/pages/Forms/StepForm/Step2' },
  41. // { path: 'result', component: './src/pages/Forms/StepForm/Step3' },
  42. // ],
  43. // },
  44. // { path: 'form/advanced-form', component: './src/pages/Forms/AdvancedForm' },
  45. // // list
  46. // { path: 'list/table-list', component: './src/pages/List/TableList' },
  47. // { path: 'list/table-list', component: './src/pages/List/TableList' },
  48. // { path: 'list/basic-list', component: './src/pages/List/BasicList' },
  49. // { path: 'list/card-list', component: './src/pages/List/CardList' },
  50. // {
  51. // path: 'list/search',
  52. // component: './src/pages/List/List',
  53. // indexRoute: { redirect: '/list/search/projects' },
  54. // childRoutes: [
  55. // { path: 'articles', component: './src/pages/List/Articles' },
  56. // { path: 'projects', component: './src/pages/List/Projects' },
  57. // { path: 'applications', component: './src/pages/List/Applications' },
  58. // ],
  59. // },
  60. // // profile
  61. // { path: 'profile/basic', component: './src/pages/Profile/BasicProfile' },
  62. // { path: 'profile/advanced', component: './src/pages/Profile/AdvancedProfile' },
  63. // // result
  64. // { path: 'result/success', component: './src/pages/Result/Success' },
  65. // { path: 'result/fail', component: './src/pages/Result/Error' },
  66. // // exception
  67. // { path: 'exception/403', component: './src/pages/Exception/403' },
  68. // { path: 'exception/404', component: './src/pages/Exception/404' },
  69. // { path: 'exception/500', component: './src/pages/Exception/500' },
  70. // // ],
  71. // }],
  72. // copy from old webpackrc.js
  73. // entry: 'src/index.js', // TODO remove
  74. extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
  75. env: {
  76. development: {
  77. extraBabelPlugins: ['dva-hmr'],
  78. },
  79. },
  80. externals: {
  81. '@antv/data-set': 'DataSet',
  82. bizcharts: 'BizCharts',
  83. rollbar: 'rollbar',
  84. },
  85. alias: {
  86. components: path.resolve(__dirname, '../src/components/'),
  87. utils: path.resolve(__dirname, '../src/utils/'),
  88. assets: path.resolve(__dirname, '../src/assets/'),
  89. common: path.resolve(__dirname, '../src/common/'),
  90. },
  91. ignoreMomentLocale: true,
  92. theme: './src/theme.js',
  93. // html: { TODO remove
  94. // template: './src/index.ejs',
  95. // },
  96. publicPath: '/',
  97. // TODO check hash config
  98. // hash: true,
  99. lessLoaderOptions: {
  100. javascriptEnabled: true,
  101. },
  102. cssLoaderOptions: {
  103. modules: true,
  104. getLocalIdent: (context, localIdentName, localName) => {
  105. if (
  106. context.resourcePath.includes('node_modules') ||
  107. context.resourcePath.includes('ant.design.pro.less')
  108. ) {
  109. return localName;
  110. }
  111. const antdProPath = context.resourcePath.match(/src(.*)/)[1].replace('.less', '');
  112. const arr = antdProPath
  113. .split('/')
  114. .map(a => a.replace(/([A-Z])/g, '-$1'))
  115. .map(a => a.toLowerCase());
  116. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  117. },
  118. },
  119. };