config.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. ...(
  23. require('os').platform() === 'darwin'
  24. ? {
  25. dll: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  26. hardSource: true,
  27. }
  28. : {}
  29. ),
  30. },
  31. ],
  32. ],
  33. // 路由配置
  34. routes: pageRoutes,
  35. theme: {
  36. 'card-actions-background': '#f5f8fa',
  37. },
  38. externals: {
  39. '@antv/data-set': 'DataSet',
  40. rollbar: 'rollbar',
  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. } else {
  64. return localName;
  65. }
  66. },
  67. },
  68. manifest: {
  69. name: 'ant-design-pro',
  70. background_color: '#FFF',
  71. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  72. display: 'standalone',
  73. start_url: '/index.html',
  74. icons: [
  75. {
  76. src: '/favicon.png',
  77. sizes: '48x48',
  78. type: 'image/png',
  79. },
  80. ],
  81. },
  82. chainWebpack: webpackplugin,
  83. };