config.js 2.8 KB

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