config.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. ...(
  22. require('os').platform() === 'darwin'
  23. ? {
  24. dll: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  25. hardSource: true,
  26. }
  27. : {}
  28. ),
  29. },
  30. ],
  31. ],
  32. // 路由配置
  33. routes: pageRoutes,
  34. theme: {
  35. 'card-actions-background': '#f5f8fa',
  36. },
  37. externals: {
  38. '@antv/data-set': 'DataSet',
  39. rollbar: 'rollbar',
  40. },
  41. alias: {
  42. components: path.resolve(__dirname, '../src/components/'),
  43. utils: path.resolve(__dirname, '../src/utils/'),
  44. assets: path.resolve(__dirname, '../src/assets/'),
  45. common: path.resolve(__dirname, '../src/common/'),
  46. },
  47. ignoreMomentLocale: true,
  48. lessLoaderOptions: {
  49. javascriptEnabled: true,
  50. },
  51. cssLoaderOptions: {
  52. modules: true,
  53. getLocalIdent: (context, localIdentName, localName) => {
  54. if (
  55. context.resourcePath.includes('node_modules') ||
  56. context.resourcePath.includes('ant.design.pro.less')
  57. ) {
  58. return localName;
  59. }
  60. const match = context.resourcePath.match(/src(.*)/);
  61. if (match && match[1]) {
  62. const antdProPath = match[1].replace('.less', '');
  63. const arr = antdProPath
  64. .split('/')
  65. .map(a => a.replace(/([A-Z])/g, '-$1'))
  66. .map(a => a.toLowerCase());
  67. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  68. } else {
  69. return localName;
  70. }
  71. },
  72. },
  73. manifest: {
  74. name: 'ant-design-pro',
  75. background_color: '#FFF',
  76. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  77. display: 'standalone',
  78. start_url: '/index.html',
  79. icons: [
  80. {
  81. src: '/favicon.png',
  82. sizes: '48x48',
  83. type: 'image/png',
  84. },
  85. ],
  86. },
  87. chainWebpack: webpackplugin,
  88. };