config.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import os from 'os';
  2. import pageRoutes from './router.config';
  3. const isDev = process.env.NODE_ENV === "development";
  4. const publicPath = isDev ? '/' : './';
  5. export default {
  6. targets: { // 配置浏览器最低版本
  7. ie: 9,
  8. },
  9. // exportStatic: {}, // 导出全部路由为静态页面
  10. plugins: [
  11. [
  12. 'umi-plugin-react',
  13. {
  14. antd: true,
  15. dva: {
  16. hmr: true
  17. },
  18. targets: {
  19. ie: 11,
  20. },
  21. locale: {
  22. enable: true, // default false
  23. default: 'zh-CN', // default zh-CN
  24. baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
  25. },
  26. // dynamicImport: true,
  27. ...(!process.env.TEST && os.platform() === 'darwin'
  28. ? {
  29. dll: {
  30. include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  31. exclude: ['@babel/runtime'],
  32. },
  33. hardSource: false,
  34. pwa: false
  35. }
  36. : {}),
  37. },
  38. ],
  39. [
  40. 'umi-plugin-ga',
  41. {
  42. code: 'UA-72788897-6',
  43. judge: () => process.env.APP_TYPE === 'site',
  44. },
  45. ],
  46. ],
  47. externals: {
  48. '@antv/data-set': 'DataSet',
  49. },
  50. ignoreMomentLocale: true,
  51. lessLoaderOptions: {
  52. javascriptEnabled: true,
  53. },
  54. disableRedirectHoist: true,
  55. cssLoaderOptions: {
  56. modules: true,
  57. getLocalIdent: (context, localIdentName, localName) => {
  58. if (
  59. context.resourcePath.includes('node_modules') ||
  60. context.resourcePath.includes('ant.design.pro.less') ||
  61. context.resourcePath.includes('global.less')
  62. ) {
  63. return localName;
  64. }
  65. const match = context.resourcePath.match(/src(.*)/);
  66. if (match && match[1]) {
  67. const antdProPath = match[1].replace('.less', '');
  68. const arr = antdProPath
  69. .split('/')
  70. .map(a => a.replace(/([A-Z])/g, '-$1'))
  71. .map(a => a.toLowerCase());
  72. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  73. }
  74. return localName;
  75. },
  76. },
  77. theme: {
  78. 'primary-color': '#E14C46',
  79. 'icon-normal-color': '#333',
  80. 'icon-disable-color': '#CCC',
  81. "card-actions-background": "#f5f8fa",
  82. "user-login-header-background": "rgb(248, 228, 228)"
  83. },
  84. // 路由配置
  85. history: 'hash',
  86. routes: pageRoutes,
  87. publicPath: publicPath,
  88. hash: !isDev,
  89. devtool: isDev? "cheap-module-eval-source-map":"cheap-module-source-map",
  90. proxy: {
  91. "/wbalone/open/getEncryptParam": {
  92. target: "http://zt.maydos.com.cn/wbalone/open/getEncryptParam",
  93. changeOrigin: true,
  94. pathRewrite: { "^/wbalone/open/getEncryptParam" : "" }
  95. },
  96. "/wbalone/account/login": {
  97. target: "http://zt.maydos.com.cn/wbalone/account/login",
  98. changeOrigin: true,
  99. pathRewrite: { "^/wbalone/account/login" : "" }
  100. },
  101. "/occ-cmpt": {
  102. target: "http://zt.maydos.com.cn/occ-cmpt",
  103. changeOrigin: true,
  104. pathRewrite: { "^/occ-cmpt" : "" }
  105. },
  106. "/g1": {
  107. target: "http://zt.maydos.com.cn/g1",
  108. changeOrigin: true,
  109. pathRewrite: { "^/g1" : "" }
  110. },
  111. "/occ-": {
  112. target: "http://zt.maydos.com.cn",
  113. changeOrigin: true,
  114. pathRewrite: { "^/" : "/" }
  115. },
  116. },
  117. manifest: {
  118. name: 'CHANNEL CLOUD',
  119. background_color: '#FFF',
  120. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  121. display: 'standalone',
  122. start_url: '/index.html',
  123. icons: [
  124. {
  125. src: '/favicon.png',
  126. sizes: '48x48',
  127. type: 'image/png',
  128. },
  129. ],
  130. },
  131. };