config.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import defaultSettings from './defaultSettings'; // https://umijs.org/config/
  2. import { chainWebpack } from './plugin.config'
  3. import slash from 'slash2';
  4. import themePluginConfig from './themePluginConfig';
  5. const { pwa } = defaultSettings; // preview.pro.ant.design only do not use in your production ;
  6. // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
  7. import { routerConfig } from './routerConfig.js';
  8. const autoprefixer = require('autoprefixer')
  9. const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env;
  10. const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site';
  11. const plugins = [
  12. [
  13. 'umi-plugin-react',
  14. {
  15. antd: true,
  16. dva: {
  17. hmr: true,
  18. },
  19. locale: {
  20. enable: true,
  21. default: 'zh-CN',
  22. baseNavigator: true,
  23. },
  24. // dynamicImport: {
  25. // loadingComponent: './components/PageLoading/index',
  26. // webpackChunkName: true,
  27. // level: 3,
  28. // },
  29. pwa: pwa
  30. ? {
  31. workboxPluginMode: 'InjectManifest',
  32. workboxOptions: {
  33. importWorkboxFrom: 'local',
  34. },
  35. }
  36. : false, // default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665
  37. headScripts: [
  38. // 'https://cdn.bootcss.com/react/16.8.6/umd/react.production.min.js',
  39. // 'https://cdn.bootcss.com/react-dom/16.8.6/umd/react-dom.production.min.js',
  40. // 'https://cdn.bootcss.com/moment.js/2.24.0/moment.min.js',
  41. // 'https://cdn.bootcss.com/moment.js/2.24.0/locale/zh-cn.js',
  42. // 'https://cdn.bootcss.com/antd/3.26.2/antd.min.js',
  43. // 'https://cdn.bootcss.com/echarts/4.6.0/echarts.min.js',
  44. 'http://sp.qn.timichat.com/assets/AgoraRTCSDK/3.0.2/AgoraRTCSDK-3.0.2.js'
  45. ],
  46. // links: [{
  47. // href: 'https://cdn.bootcss.com/antd/3.26.2/antd.min.css', rel: 'stylesheet', type: 'text/css'
  48. // }]
  49. },
  50. ],
  51. [
  52. 'umi-plugin-pro-block',
  53. {
  54. moveMock: false,
  55. moveService: false,
  56. modifyRequest: true,
  57. autoAddMenu: true,
  58. },
  59. ]
  60. ];
  61. if (isAntDesignProPreview) {
  62. // 针对 preview.pro.ant.design 的 GA 统计代码
  63. plugins.push([
  64. 'umi-plugin-ga',
  65. {
  66. code: 'UA-72788897-6',
  67. },
  68. ]);
  69. plugins.push(['umi-plugin-antd-theme', themePluginConfig]);
  70. }
  71. export default {
  72. plugins,
  73. hash: true,
  74. targets: {
  75. ie: 9,
  76. },
  77. routes: routerConfig,
  78. // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  79. theme: {
  80. // ...darkTheme,
  81. 'primary-color': '#ff4d5c',
  82. },
  83. define: {
  84. ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
  85. ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
  86. },
  87. ignoreMomentLocale: true,
  88. lessLoaderOptions: {
  89. javascriptEnabled: true,
  90. },
  91. disableRedirectHoist: true,
  92. cssLoaderOptions: {
  93. modules: true,
  94. getLocalIdent: (context, _, localName) => {
  95. if (
  96. context.resourcePath.includes('node_modules') ||
  97. context.resourcePath.includes('ant.design.pro.less') ||
  98. context.resourcePath.includes('global.less')
  99. ) {
  100. return localName;
  101. }
  102. const match = context.resourcePath.match(/src(.*)/);
  103. if (match && match[1]) {
  104. const antdProPath = match[1].replace('.less', '');
  105. const arr = slash(antdProPath)
  106. .split('/')
  107. .map(a => a.replace(/([A-Z])/g, '-$1'))
  108. .map(a => a.toLowerCase());
  109. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  110. }
  111. return localName;
  112. },
  113. },
  114. extraPostCSSPlugins: [
  115. autoprefixer({
  116. flexbox: true
  117. })
  118. ],
  119. manifest: {
  120. basePath: '/',
  121. },
  122. // chainWebpack: chainWebpack,
  123. proxy: {
  124. '/api-manage': {
  125. target: 'http://api.timichat.net',
  126. changeOrigin: true,
  127. //pathRewrite: { '^/server': '' },
  128. },
  129. '/api-common': {
  130. target: 'http://api.timichat.net',
  131. changeOrigin: true,
  132. //pathRewrite: { '^/server': '' },
  133. },
  134. '/rongcloud': {
  135. target: 'http://message.ronghub.com',
  136. changeOrigin: true,
  137. pathRewrite: { '^/rongcloud': '' },
  138. }
  139. },
  140. treeShaking: true,
  141. mock: {
  142. exclude: [],
  143. },
  144. publicPath: '/',
  145. // outputPath: './manage',
  146. };