config.js 2.4 KB

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