config.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. },
  43. ],
  44. ],
  45. targets: {
  46. ie: 11,
  47. },
  48. define: {
  49. APP_TYPE: process.env.APP_TYPE || '',
  50. },
  51. // 路由配置
  52. routes: pageRoutes,
  53. // Theme for antd
  54. // https://ant.design/docs/react/customize-theme-cn
  55. theme: {
  56. 'primary-color': defaultSettings.primaryColor,
  57. },
  58. externals: {
  59. '@antv/data-set': 'DataSet',
  60. },
  61. // proxy: {
  62. // '/server/api/': {
  63. // target: 'https://preview.pro.ant.design/',
  64. // changeOrigin: true,
  65. // pathRewrite: { '^/server': '' },
  66. // },
  67. // },
  68. ignoreMomentLocale: true,
  69. lessLoaderOptions: {
  70. javascriptEnabled: true,
  71. },
  72. disableRedirectHoist: true,
  73. cssLoaderOptions: {
  74. modules: true,
  75. getLocalIdent: (context, localIdentName, localName) => {
  76. if (
  77. context.resourcePath.includes('node_modules') ||
  78. context.resourcePath.includes('ant.design.pro.less') ||
  79. context.resourcePath.includes('global.less')
  80. ) {
  81. return localName;
  82. }
  83. const match = context.resourcePath.match(/src(.*)/);
  84. if (match && match[1]) {
  85. const antdProPath = match[1].replace('.less', '');
  86. const arr = antdProPath
  87. .split('/')
  88. .map(a => a.replace(/([A-Z])/g, '-$1'))
  89. .map(a => a.toLowerCase());
  90. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  91. }
  92. return localName;
  93. },
  94. },
  95. manifest: {
  96. name: 'ant-design-pro',
  97. background_color: '#FFF',
  98. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  99. display: 'standalone',
  100. start_url: '/index.html',
  101. icons: [
  102. {
  103. src: '/favicon.png',
  104. sizes: '48x48',
  105. type: 'image/png',
  106. },
  107. ],
  108. },
  109. chainWebpack: webpackplugin,
  110. cssnano: {
  111. mergeRules: false,
  112. },
  113. };