config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  28. hardSource: true,
  29. }
  30. : {}),
  31. },
  32. ],
  33. ],
  34. // 路由配置
  35. routes: pageRoutes,
  36. // Theme for antd
  37. // https://ant.design/docs/react/customize-theme-cn
  38. theme: {
  39. 'primary-color': defaultSettings.primaryColor,
  40. },
  41. externals: {
  42. '@antv/data-set': 'DataSet',
  43. },
  44. ignoreMomentLocale: true,
  45. lessLoaderOptions: {
  46. javascriptEnabled: true,
  47. },
  48. cssLoaderOptions: {
  49. modules: true,
  50. getLocalIdent: (context, localIdentName, localName) => {
  51. if (
  52. context.resourcePath.includes('node_modules') ||
  53. context.resourcePath.includes('ant.design.pro.less') ||
  54. context.resourcePath.includes('global.less')
  55. ) {
  56. return localName;
  57. }
  58. const match = context.resourcePath.match(/src(.*)/);
  59. if (match && match[1]) {
  60. const antdProPath = match[1].replace('.less', '');
  61. const arr = antdProPath
  62. .split('/')
  63. .map(a => a.replace(/([A-Z])/g, '-$1'))
  64. .map(a => a.toLowerCase());
  65. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  66. }
  67. return localName;
  68. },
  69. },
  70. manifest: {
  71. name: 'ant-design-pro',
  72. background_color: '#FFF',
  73. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  74. display: 'standalone',
  75. start_url: '/index.html',
  76. icons: [
  77. {
  78. src: '/favicon.png',
  79. sizes: '48x48',
  80. type: 'image/png',
  81. },
  82. ],
  83. },
  84. chainWebpack: webpackplugin,
  85. cssnano: {
  86. mergeRules: false,
  87. },
  88. };