config.uat.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // https://umijs.org/config/
  2. import os from 'os'
  3. import path from 'path'
  4. import pageRoutes from './router.config'
  5. import webpackPlugin from './plugin.config'
  6. import defaultSettings from './defaultSettings'
  7. const plugins = [
  8. [
  9. 'umi-plugin-react',
  10. {
  11. // antd: true,
  12. dva: {
  13. hmr: true
  14. },
  15. targets: {
  16. ie: 11
  17. },
  18. locale: {
  19. enable: true, // default false
  20. default: 'zh-CN', // default zh-CN
  21. baseNavigator: true // default true, when it is true, will use `navigator.language` overwrite default
  22. },
  23. dynamicImport: {
  24. loadingComponent: './components/PageLoading/index',
  25. webpackChunkName: true,
  26. level: 3
  27. },
  28. ...(!process.env.TEST && os.platform() === 'darwin'
  29. ? {
  30. dll: {
  31. include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  32. exclude: ['@babel/runtime']
  33. }
  34. }
  35. : {})
  36. }
  37. ]
  38. ]
  39. // 复制signalR
  40. const copy = [
  41. {
  42. from: path.join(__dirname, '../node_modules/@aspnet/signalr/dist/browser/signalr.min.js'),
  43. to: path.join(__dirname, '../dist')
  44. },
  45. {
  46. from: path.join(
  47. __dirname,
  48. '../node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.signalr-client.js'
  49. ),
  50. to: path.join(__dirname, '../dist')
  51. }
  52. ]
  53. // const APP_API_URL = 'http://59.37.167.93:8095';
  54. const base = 'pages'
  55. const publicPath = `/`
  56. export default {
  57. // publicPath,
  58. // base, // 指定 react-router 的 base,部署到非根目录时需要配置
  59. // publicPath: `/${APP_BASE}/`, // 指向静态资源的目录
  60. extraBabelPlugins: [
  61. // ['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }],
  62. ['lodash'] // lodash-webpack-plugin
  63. ],
  64. history: 'hash',
  65. // add for transfer to umi
  66. hash: true, // 是否开启 hash 文件后缀
  67. plugins,
  68. targets: {
  69. ie: 11
  70. },
  71. define: {
  72. BAIDU_MAP_AK: '4CK0UtaFanYgeyVA4RbBNZTS6CFedMgM',
  73. QQ_MAP_AK: 'SW7BZ-LY33F-JEXJW-JWNBE-UCEEE-64BPI',
  74. APP_TYPE: process.env.APP_TYPE || '',
  75. APP_BASE_URL: 'https://muat.zsdhome.cn/',
  76. REMOTE_SERVICE_BASE_URL: 'https://portaluat.zsdhome.cn',
  77. APP_API_MATERIAL_UPLOAD_URL: 'https://portaluat.zsdhome.cn/api/Material/Upload',
  78. APP_API_MATERIAL_UPLOAD_PANORAMA_URL:
  79. 'https://portaluat.zsdhome.cn/api/Material/UploadPanorama',
  80. APP_API_MATERIAL_UPLOAD_TOPIC_URL: 'https://portaluat.zsdhome.cn/api/Material/UploadTopic',
  81. APP_API_MATERIAL_UPLOAD_VIDEO_URL: 'https://portaluat.zsdhome.cn/api/Material/UploadVideo',
  82. APP_ABP_SIGNALR_CLIENT_JS_URL: `abp.signalr-client.js`,
  83. APP_AVATAR_IMAGE_URL:
  84. 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png'
  85. },
  86. treeShaking: true,
  87. // 路由配置
  88. routes: pageRoutes,
  89. // Theme for antd
  90. // https://ant.design/docs/react/customize-theme-cn
  91. theme: {
  92. 'primary-color': defaultSettings.primaryColor
  93. },
  94. copy,
  95. externals: {
  96. react: 'React',
  97. 'react-dom': 'ReactDOM',
  98. 'react-dom/server': 'ReactDOMServer',
  99. antd: 'antd',
  100. moment: 'moment',
  101. tinymce: 'tinymce'
  102. },
  103. // alias: {
  104. // // 在 Ant Design (Antd) 中使用 Day.js 替换 Moment
  105. // // https://github.com/iamkun/dayjs/issues/529
  106. // moment: 'dayjs',
  107. // },
  108. ignoreMomentLocale: true,
  109. lessLoaderOptions: {
  110. javascriptEnabled: true
  111. },
  112. devtool: false, // 没有关闭source-map
  113. disableRedirectHoist: true,
  114. disableCSSSourceMap: true, // 禁用 CSS 的 SourceMap 生成
  115. cssLoaderOptions: {
  116. modules: true,
  117. getLocalIdent: (context, localIdentName, localName) => {
  118. if (
  119. context.resourcePath.includes('node_modules') ||
  120. context.resourcePath.includes('ant.design.pro.less') ||
  121. context.resourcePath.includes('global.less') ||
  122. context.resourcePath.includes('src/layouts/ChatLayout.less') ||
  123. context.resourcePath.includes('react-contextmenu.less')
  124. ) {
  125. return localName
  126. }
  127. // const chatMatch = context.resourcePath.match(/Chat|WebIm(.*)/);
  128. const chatMatch = context.resourcePath.match(/Chat(.*)/)
  129. if (chatMatch && chatMatch[1]) {
  130. return localName
  131. }
  132. const webImMatch = context.resourcePath.match(/WebIm(.*)/)
  133. if (webImMatch && webImMatch[1]) {
  134. return localName
  135. }
  136. const match = context.resourcePath.match(/src(.*)/)
  137. if (match && match[1]) {
  138. const antdProPath = match[1].replace('.less', '')
  139. const arr = antdProPath
  140. .split('/')
  141. .map(a => a.replace(/([A-Z])/g, '-$1'))
  142. .map(a => a.toLowerCase())
  143. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-')
  144. }
  145. return localName
  146. }
  147. },
  148. manifest: {
  149. basePath: '/'
  150. },
  151. chainWebpack: webpackPlugin
  152. }