config.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. (!process.env.TEST && 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. alias: {
  43. components: path.resolve(__dirname, '../src/components/'),
  44. utils: path.resolve(__dirname, '../src/utils/'),
  45. assets: path.resolve(__dirname, '../src/assets/'),
  46. common: path.resolve(__dirname, '../src/common/'),
  47. },
  48. ignoreMomentLocale: true,
  49. lessLoaderOptions: {
  50. javascriptEnabled: true,
  51. },
  52. cssLoaderOptions: {
  53. modules: true,
  54. getLocalIdent: (context, localIdentName, localName) => {
  55. if (
  56. context.resourcePath.includes('node_modules') ||
  57. context.resourcePath.includes('ant.design.pro.less')
  58. ) {
  59. return localName;
  60. }
  61. const match = context.resourcePath.match(/src(.*)/);
  62. if (match && match[1]) {
  63. const antdProPath = match[1].replace('.less', '');
  64. const arr = antdProPath
  65. .split('/')
  66. .map(a => a.replace(/([A-Z])/g, '-$1'))
  67. .map(a => a.toLowerCase());
  68. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  69. } else {
  70. return localName;
  71. }
  72. },
  73. },
  74. manifest: {
  75. name: 'ant-design-pro',
  76. background_color: '#FFF',
  77. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  78. display: 'standalone',
  79. start_url: '/index.html',
  80. icons: [
  81. {
  82. src: '/favicon.png',
  83. sizes: '48x48',
  84. type: 'image/png',
  85. },
  86. ],
  87. },
  88. chainWebpack: webpackplugin,
  89. cssnano: {
  90. mergeRules: false,
  91. },
  92. };