config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. locale: {
  17. enable: true, // default false
  18. default: 'zh-CN', // default zh-CN
  19. baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
  20. },
  21. dynamicImport: {
  22. loadingComponent: './components/PageLoading/index',
  23. },
  24. polyfills: ['ie11'],
  25. ...(!process.env.TEST && os.platform() === 'darwin'
  26. ? {
  27. dll: {
  28. include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  29. exclude: ['@babel/runtime'],
  30. },
  31. hardSource: true,
  32. }
  33. : {}),
  34. },
  35. ],
  36. [
  37. 'umi-plugin-ga',
  38. {
  39. code: 'UA-72788897-6',
  40. },
  41. ],
  42. ],
  43. define: {
  44. APP_TYPE: process.env.APP_TYPE || '',
  45. },
  46. // 路由配置
  47. routes: pageRoutes,
  48. // Theme for antd
  49. // https://ant.design/docs/react/customize-theme-cn
  50. theme: {
  51. 'primary-color': defaultSettings.primaryColor,
  52. },
  53. externals: {
  54. '@antv/data-set': 'DataSet',
  55. },
  56. ignoreMomentLocale: true,
  57. lessLoaderOptions: {
  58. javascriptEnabled: true,
  59. },
  60. cssLoaderOptions: {
  61. modules: true,
  62. getLocalIdent: (context, localIdentName, localName) => {
  63. if (
  64. context.resourcePath.includes('node_modules') ||
  65. context.resourcePath.includes('ant.design.pro.less') ||
  66. context.resourcePath.includes('global.less')
  67. ) {
  68. return localName;
  69. }
  70. const match = context.resourcePath.match(/src(.*)/);
  71. if (match && match[1]) {
  72. const antdProPath = match[1].replace('.less', '');
  73. const arr = antdProPath
  74. .split('/')
  75. .map(a => a.replace(/([A-Z])/g, '-$1'))
  76. .map(a => a.toLowerCase());
  77. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  78. }
  79. return localName;
  80. },
  81. },
  82. manifest: {
  83. name: 'ant-design-pro',
  84. background_color: '#FFF',
  85. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  86. display: 'standalone',
  87. start_url: '/index.html',
  88. icons: [
  89. {
  90. src: '/favicon.png',
  91. sizes: '48x48',
  92. type: 'image/png',
  93. },
  94. ],
  95. },
  96. chainWebpack: webpackplugin,
  97. cssnano: {
  98. mergeRules: false,
  99. },
  100. };