config.js 4.3 KB

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