config.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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, // 启用后自动配置 babel-plugin-import 实现 antd, antd-mobile 和 antd-pro 的按需编译,并且内置 antd, antd-mobile 依赖,无需手动在项目中安装
  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(__dirname, '../node_modules/@aspnet/signalr/dist/browser/signalr.min.js.map'),
  47. to: path.join(__dirname, '../dist')
  48. },
  49. {
  50. from: path.join(
  51. __dirname,
  52. '../node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.signalr-client.js'
  53. ),
  54. to: path.join(__dirname, '../dist')
  55. }
  56. ]
  57. export default {
  58. extraBabelPlugins: [
  59. // ['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }],
  60. ['lodash'] // lodash-webpack-plugin
  61. ],
  62. history: 'hash',
  63. hash: true, // 是否开启 hash 文件后缀
  64. // add for transfer to umi
  65. plugins,
  66. targets: {
  67. ie: 11
  68. },
  69. define: {
  70. BAIDU_MAP_AK: '4CK0UtaFanYgeyVA4RbBNZTS6CFedMgM',
  71. // QQ_MAP_AK: 'SW7BZ-LY33F-JEXJW-JWNBE-UCEEE-64BPI',
  72. QQ_MAP_AK: 'I5NBZ-NA2HU-Y62VT-2HYXF-KJLQS-3VBEY',
  73. APP_TYPE: process.env.APP_TYPE || '',
  74. APP_BASE_URL: 'http://localhost:8000/',
  75. REMOTE_SERVICE_BASE_URL: 'http://localhost:21021',
  76. APP_API_MATERIAL_UPLOAD_URL: 'http://localhost:21021/api/Material/Upload', //这里设置成本地连接才能正确的在后台IM中收发消息
  77. // APP_API_MATERIAL_UPLOAD_URL: 'http://localhost:21021/api/Material/Upload',
  78. APP_API_MATERIAL_UPLOAD_PANORAMA_URL: 'http://localhost:21021/api/Material/UploadPanorama',
  79. APP_API_MATERIAL_UPLOAD_TOPIC_URL: 'http://localhost:21021/api/Material/UploadTopic',
  80. APP_API_MATERIAL_UPLOAD_VIDEO_URL: 'http://localhost:21021/api/Material/UploadVideo',
  81. APP_ABP_SIGNALR_CLIENT_JS_URL: `abp.signalr-client.js`,
  82. APP_AVATAR_IMAGE_URL:
  83. 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png'
  84. },
  85. treeShaking: true,
  86. // 路由配置
  87. routes: pageRoutes,
  88. // Theme for antd
  89. // https://ant.design/docs/react/customize-theme-cn
  90. theme: {
  91. 'primary-color': '#eda92a',
  92. 'layout-header-height': '40px',
  93. 'line-height-base': '1',
  94. 'link-color': '#e89a08',
  95. 'table-header-sort-active-bg': '#efefef',
  96. 'table-header-filter-active-bg': '#e0e0e0'
  97. },
  98. copy,
  99. externals: {
  100. // 'gg-editor': 'GGEditor',
  101. // react: 'React',
  102. // 'react-dom': 'ReactDOM',
  103. // 'react-dom/server': 'ReactDOMServer',
  104. // 'react-beautiful-dnd': 'ReactBeautifulDnd',
  105. // '@antv/data-set': 'DataSet',
  106. // '@antv/g6': 'G6',
  107. // antd: 'antd',
  108. // moment: 'moment',
  109. tinymce: 'tinymce'
  110. },
  111. // alias: {
  112. // // 在 Ant Design (Antd) 中使用 Day.js 替换 Moment
  113. // // https://github.com/iamkun/dayjs/issues/529
  114. // moment: 'dayjs',
  115. // },
  116. devtool: 'inline-source-map',
  117. ignoreMomentLocale: true,
  118. lessLoaderOptions: {
  119. javascriptEnabled: true
  120. },
  121. disableRedirectHoist: true,
  122. cssLoaderOptions: {
  123. modules: true,
  124. getLocalIdent: (context, localIdentName, localName) => {
  125. if (
  126. context.resourcePath.includes('node_modules') ||
  127. context.resourcePath.includes('ant.design.pro.less') ||
  128. context.resourcePath.includes('global.less') ||
  129. context.resourcePath.includes('src/layouts/ChatLayout.less') ||
  130. context.resourcePath.includes('react-contextmenu.less')
  131. ) {
  132. return localName
  133. }
  134. // const chatMatch = context.resourcePath.match(/src\/pages\/Chat(.*)/i);
  135. // if (chatMatch && chatMatch[1]) {
  136. // return localName;
  137. // }
  138. // const chatComponents = context.resourcePath.match(/src\/components\/Chat(.*)/i);
  139. // if (chatComponents && chatComponents[1]) {
  140. // return localName;
  141. // }
  142. //上面的代码windows读取不到路径
  143. const chatMatch = context.resourcePath.match(/Chat(.*)/)
  144. if (chatMatch && chatMatch[1]) {
  145. return localName
  146. }
  147. const webImMatch = context.resourcePath.match(/WebIm(.*)/)
  148. if (webImMatch && webImMatch[1]) {
  149. return localName
  150. }
  151. const match = context.resourcePath.match(/src(.*)/)
  152. if (match && match[1]) {
  153. const antdProPath = match[1].replace('.less', '')
  154. const arr = antdProPath
  155. .split('/')
  156. .map(a => a.replace(/([A-Z])/g, '-$1'))
  157. .map(a => a.toLowerCase())
  158. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-')
  159. }
  160. return localName
  161. }
  162. },
  163. manifest: {
  164. basePath: '/'
  165. },
  166. chainWebpack: webpackPlugin
  167. }