config.js 2.3 KB

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