config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // https://umijs.org/config/
  2. import os from 'os';
  3. import pageRoutes from './router.config';
  4. import webpackPlugin from './plugin.config';
  5. import defaultSettings from '../src/defaultSettings';
  6. export default {
  7. // add for transfer to umi
  8. plugins: [
  9. [
  10. 'umi-plugin-react',
  11. {
  12. antd: true,
  13. dva: {
  14. hmr: true,
  15. },
  16. targets: {
  17. ie: 11,
  18. },
  19. locale: {
  20. enable: true, // default false
  21. default: 'zh-CN', // default zh-CN
  22. baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
  23. },
  24. dynamicImport: {
  25. loadingComponent: './components/PageLoading/index',
  26. },
  27. ...(!process.env.TEST && os.platform() === 'darwin'
  28. ? {
  29. dll: {
  30. include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  31. exclude: ['@babel/runtime'],
  32. },
  33. hardSource: true,
  34. }
  35. : {}),
  36. },
  37. ],
  38. [
  39. 'umi-plugin-ga',
  40. {
  41. code: 'UA-72788897-6',
  42. judge: () => process.env.APP_TYPE === 'site',
  43. },
  44. ],
  45. ],
  46. targets: {
  47. ie: 11,
  48. },
  49. define: {
  50. APP_TYPE: process.env.APP_TYPE || '',
  51. },
  52. // 路由配置
  53. routes: pageRoutes,
  54. // Theme for antd
  55. // https://ant.design/docs/react/customize-theme-cn
  56. theme: {
  57. 'primary-color': defaultSettings.primaryColor,
  58. },
  59. externals: {
  60. '@antv/data-set': 'DataSet',
  61. },
  62. // proxy: {
  63. // '/server/api/': {
  64. // target: 'https://preview.pro.ant.design/',
  65. // changeOrigin: true,
  66. // pathRewrite: { '^/server': '' },
  67. // },
  68. // },
  69. ignoreMomentLocale: true,
  70. lessLoaderOptions: {
  71. javascriptEnabled: true,
  72. },
  73. disableRedirectHoist: true,
  74. cssLoaderOptions: {
  75. modules: true,
  76. getLocalIdent: (context, localIdentName, localName) => {
  77. if (
  78. context.resourcePath.includes('node_modules') ||
  79. context.resourcePath.includes('ant.design.pro.less') ||
  80. context.resourcePath.includes('global.less')
  81. ) {
  82. return localName;
  83. }
  84. const match = context.resourcePath.match(/src(.*)/);
  85. if (match && match[1]) {
  86. const antdProPath = match[1].replace('.less', '');
  87. const arr = antdProPath
  88. .split('/')
  89. .map(a => a.replace(/([A-Z])/g, '-$1'))
  90. .map(a => a.toLowerCase());
  91. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  92. }
  93. return localName;
  94. },
  95. },
  96. manifest: {
  97. basePath:"/"
  98. },
  99. chainWebpack: webpackPlugin,
  100. cssnano: {
  101. mergeRules: false,
  102. },
  103. };