config.js 2.5 KB

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