config.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. ) {
  55. return localName;
  56. }
  57. const match = context.resourcePath.match(/src(.*)/);
  58. if (match && match[1]) {
  59. const antdProPath = match[1].replace('.less', '');
  60. const arr = antdProPath
  61. .split('/')
  62. .map(a => a.replace(/([A-Z])/g, '-$1'))
  63. .map(a => a.toLowerCase());
  64. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  65. }
  66. return localName;
  67. },
  68. },
  69. manifest: {
  70. name: 'ant-design-pro',
  71. background_color: '#FFF',
  72. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  73. display: 'standalone',
  74. start_url: '/index.html',
  75. icons: [
  76. {
  77. src: '/favicon.png',
  78. sizes: '48x48',
  79. type: 'image/png',
  80. },
  81. ],
  82. },
  83. chainWebpack: webpackplugin,
  84. cssnano: {
  85. mergeRules: false,
  86. },
  87. };