config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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: 9,
  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. ignoreMomentLocale: true,
  62. lessLoaderOptions: {
  63. javascriptEnabled: true,
  64. },
  65. cssLoaderOptions: {
  66. modules: true,
  67. getLocalIdent: (context, localIdentName, localName) => {
  68. if (
  69. context.resourcePath.includes('node_modules') ||
  70. context.resourcePath.includes('ant.design.pro.less') ||
  71. context.resourcePath.includes('global.less')
  72. ) {
  73. return localName;
  74. }
  75. const match = context.resourcePath.match(/src(.*)/);
  76. if (match && match[1]) {
  77. const antdProPath = match[1].replace('.less', '');
  78. const arr = antdProPath
  79. .split('/')
  80. .map(a => a.replace(/([A-Z])/g, '-$1'))
  81. .map(a => a.toLowerCase());
  82. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  83. }
  84. return localName;
  85. },
  86. },
  87. manifest: {
  88. name: 'ant-design-pro',
  89. background_color: '#FFF',
  90. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  91. display: 'standalone',
  92. start_url: '/index.html',
  93. icons: [
  94. {
  95. src: '/favicon.png',
  96. sizes: '48x48',
  97. type: 'image/png',
  98. },
  99. ],
  100. },
  101. chainWebpack: webpackplugin,
  102. cssnano: {
  103. mergeRules: false,
  104. },
  105. };