config.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // https://umijs.org/config/
  2. const pageRoutes = require('./router.config');
  3. const webpackplugin = require('./plugin.config');
  4. const defaultSetting = require('../src/defaultSetting');
  5. export default {
  6. // add for transfer to umi
  7. plugins: [
  8. [
  9. 'umi-plugin-react',
  10. {
  11. antd: true,
  12. dva: {
  13. hmr: true,
  14. },
  15. locale: {
  16. enable: true, // default false
  17. default: 'zh-CN', // default zh-CN
  18. baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
  19. },
  20. dynamicImport: true,
  21. polyfills: ['ie11'],
  22. ...(!process.env.TEST && require('os').platform() === 'darwin'
  23. ? {
  24. dll: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  25. hardSource: true,
  26. }
  27. : {}),
  28. },
  29. ],
  30. ],
  31. // 路由配置
  32. routes: pageRoutes,
  33. // Theme for antd
  34. // https://ant.design/docs/react/customize-theme-cn
  35. theme: {
  36. 'primary-color': defaultSetting.primaryColor,
  37. },
  38. externals: {
  39. '@antv/data-set': 'DataSet',
  40. },
  41. ignoreMomentLocale: true,
  42. lessLoaderOptions: {
  43. javascriptEnabled: true,
  44. },
  45. cssLoaderOptions: {
  46. modules: true,
  47. getLocalIdent: (context, localIdentName, localName) => {
  48. if (
  49. context.resourcePath.includes('node_modules') ||
  50. context.resourcePath.includes('ant.design.pro.less')
  51. ) {
  52. return localName;
  53. }
  54. const match = context.resourcePath.match(/src(.*)/);
  55. if (match && match[1]) {
  56. const antdProPath = match[1].replace('.less', '');
  57. const arr = antdProPath
  58. .split('/')
  59. .map(a => a.replace(/([A-Z])/g, '-$1'))
  60. .map(a => a.toLowerCase());
  61. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  62. } else {
  63. return localName;
  64. }
  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. };