config.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // https://umijs.org/config/
  2. const pageRoutes = require('./router.config');
  3. const webpackplugin = require('./plugin.config');
  4. export default {
  5. // add for transfer to umi
  6. plugins: [
  7. [
  8. 'umi-plugin-react',
  9. {
  10. antd: true,
  11. dva: {
  12. hmr: true,
  13. },
  14. locale: {
  15. enable: true, // default false
  16. default: 'zh-CN', // default zh-CN
  17. baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
  18. },
  19. dynamicImport: true,
  20. polyfills: ['ie11'],
  21. ...(!process.env.TEST && require('os').platform() === 'darwin'
  22. ? {
  23. dll: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  24. hardSource: true,
  25. }
  26. : {}),
  27. },
  28. ],
  29. ],
  30. // 路由配置
  31. routes: pageRoutes,
  32. theme: {
  33. 'card-actions-background': '#f5f8fa',
  34. },
  35. externals: {
  36. '@antv/data-set': 'DataSet',
  37. },
  38. ignoreMomentLocale: true,
  39. lessLoaderOptions: {
  40. javascriptEnabled: true,
  41. },
  42. cssLoaderOptions: {
  43. modules: true,
  44. getLocalIdent: (context, localIdentName, localName) => {
  45. if (
  46. context.resourcePath.includes('node_modules') ||
  47. context.resourcePath.includes('ant.design.pro.less')
  48. ) {
  49. return localName;
  50. }
  51. const match = context.resourcePath.match(/src(.*)/);
  52. if (match && match[1]) {
  53. const antdProPath = match[1].replace('.less', '');
  54. const arr = antdProPath
  55. .split('/')
  56. .map(a => a.replace(/([A-Z])/g, '-$1'))
  57. .map(a => a.toLowerCase());
  58. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  59. } else {
  60. return localName;
  61. }
  62. },
  63. },
  64. manifest: {
  65. name: 'ant-design-pro',
  66. background_color: '#FFF',
  67. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  68. display: 'standalone',
  69. start_url: '/index.html',
  70. icons: [
  71. {
  72. src: '/favicon.png',
  73. sizes: '48x48',
  74. type: 'image/png',
  75. },
  76. ],
  77. },
  78. chainWebpack: webpackplugin,
  79. cssnano: {
  80. mergeRules: false,
  81. },
  82. };