config.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* eslint-disable react/destructuring-assignment */
  2. // https://umijs.org/config/
  3. const pageRoutes = require('./router.config');
  4. const webpackplugin = require('./plugin.config');
  5. const path = require('path');
  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. polyfills: ['ie9'],
  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: {
  34. 'card-actions-background': '#f5f8fa',
  35. },
  36. externals: {
  37. '@antv/data-set': 'DataSet',
  38. rollbar: 'rollbar',
  39. },
  40. ignoreMomentLocale: true,
  41. lessLoaderOptions: {
  42. javascriptEnabled: true,
  43. },
  44. cssLoaderOptions: {
  45. modules: true,
  46. getLocalIdent: (context, localIdentName, localName) => {
  47. if (
  48. context.resourcePath.includes('node_modules') ||
  49. context.resourcePath.includes('ant.design.pro.less')
  50. ) {
  51. return localName;
  52. }
  53. const match = context.resourcePath.match(/src(.*)/);
  54. if (match && match[1]) {
  55. const antdProPath = match[1].replace('.less', '');
  56. const arr = antdProPath
  57. .split('/')
  58. .map(a => a.replace(/([A-Z])/g, '-$1'))
  59. .map(a => a.toLowerCase());
  60. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  61. } else {
  62. return localName;
  63. }
  64. },
  65. },
  66. manifest: {
  67. name: 'ant-design-pro',
  68. background_color: '#FFF',
  69. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  70. display: 'standalone',
  71. start_url: '/index.html',
  72. icons: [
  73. {
  74. src: '/favicon.png',
  75. sizes: '48x48',
  76. type: 'image/png',
  77. },
  78. ],
  79. },
  80. chainWebpack: webpackplugin,
  81. cssnano: {
  82. mergeRules: false,
  83. },
  84. };