config.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // https://umijs.org/config/
  2. import os from 'os';
  3. import pageRoutes from './router.config';
  4. import webpackPlugin from './plugin.config';
  5. import defaultSettings from '../src/defaultSettings';
  6. const plugins = [
  7. [
  8. 'umi-plugin-react',
  9. {
  10. antd: true,
  11. dva: {
  12. hmr: true,
  13. },
  14. targets: {
  15. ie: 11,
  16. },
  17. locale: {
  18. enable: true, // default false
  19. default: 'zh-CN', // default zh-CN
  20. baseNavigator: false, // default true, when it is true, will use `navigator.language` overwrite default
  21. },
  22. dynamicImport: {
  23. loadingComponent: './components/PageLoading/index',
  24. },
  25. pwa: {
  26. workboxPluginMode: 'InjectManifest',
  27. workboxOptions: {
  28. importWorkboxFrom: 'local',
  29. },
  30. },
  31. ...(!process.env.TEST && os.platform() === 'darwin'
  32. ? {
  33. dll: {
  34. include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  35. exclude: ['@babel/runtime'],
  36. },
  37. }
  38. : {}),
  39. },
  40. ],
  41. ];
  42. // 针对 preview.pro.ant.design 的 GA 统计代码
  43. // 业务上不需要这个
  44. if (process.env.APP_TYPE === 'site') {
  45. plugins.push([
  46. 'umi-plugin-ga',
  47. {
  48. code: 'UA-72788897-6',
  49. },
  50. ]);
  51. }
  52. export default {
  53. // add for transfer to umi
  54. plugins,
  55. targets: {
  56. ie: 11,
  57. },
  58. define: {
  59. APP_TYPE: process.env.APP_TYPE || '',
  60. },
  61. // 路由配置
  62. routes: pageRoutes,
  63. // Theme for antd
  64. // https://ant.design/docs/react/customize-theme-cn
  65. theme: {
  66. 'primary-color': defaultSettings.primaryColor,
  67. },
  68. externals: {
  69. '@antv/data-set': 'DataSet',
  70. },
  71. proxy: {
  72. "/api/": {
  73. // target: "http://54.46.9.88:8001/",
  74. target: 'http://192.168.0.158:8001/',
  75. changeOrigin: true,
  76. pathRewrite: { "^/api": "" },
  77. },
  78. // '/api/v3/system/seller/setting/getSiteSettingList': {
  79. // target: 'http://192.168.0.158:8001/',
  80. // changeOrigin: true,
  81. // pathRewrite: { "^/api": "" },
  82. // },
  83. // '/api/v3/statistics/seller/overview/analysis/source/presentData': {
  84. // target: 'http://192.168.0.158:8001/',
  85. // changeOrigin: true,
  86. // pathRewrite: { "^/api": "" },
  87. // },
  88. // '/api/v3/goods/seller/goods/list': {
  89. // target: 'http://192.168.0.158:8001/',
  90. // changeOrigin: true,
  91. // pathRewrite: { "^/api": "" },
  92. // }
  93. },
  94. ignoreMomentLocale: true,
  95. lessLoaderOptions: {
  96. javascriptEnabled: true,
  97. },
  98. disableRedirectHoist: true,
  99. cssLoaderOptions: {
  100. modules: true,
  101. getLocalIdent: (context, localIdentName, localName) => {
  102. if (
  103. context.resourcePath.includes('node_modules') ||
  104. context.resourcePath.includes('ant.design.pro.less') ||
  105. context.resourcePath.includes('global.less')
  106. ) {
  107. return localName;
  108. }
  109. const match = context.resourcePath.match(/src(.*)/);
  110. if (match && match[1]) {
  111. const antdProPath = match[1].replace('.less', '');
  112. const arr = antdProPath
  113. .split('/')
  114. .map(a => a.replace(/([A-Z])/g, '-$1'))
  115. .map(a => a.toLowerCase());
  116. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  117. // return `${localName}`;
  118. }
  119. return localName;
  120. },
  121. },
  122. manifest: {
  123. basePath: '/',
  124. },
  125. chainWebpack: webpackPlugin,
  126. };