123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- // https://umijs.org/config/
- import os from 'os'
- import path from 'path'
- import pageRoutes from './router.config'
- import webpackPlugin from './plugin.config'
- import defaultSettings from './defaultSettings'
- const plugins = [
- [
- 'umi-plugin-react',
- {
- // antd: true, // 启用后自动配置 babel-plugin-import 实现 antd, antd-mobile 和 antd-pro 的按需编译,并且内置 antd, antd-mobile 依赖,无需手动在项目中安装
- dva: {
- hmr: true
- },
- targets: {
- ie: 11
- },
- locale: {
- enable: true, // default false
- default: 'zh-CN', // default zh-CN
- baseNavigator: true // default true, when it is true, will use `navigator.language` overwrite default
- },
- dynamicImport: {
- loadingComponent: './components/PageLoading/index',
- webpackChunkName: true,
- level: 3
- },
- ...(!process.env.TEST && os.platform() === 'darwin'
- ? {
- dll: {
- include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
- exclude: ['@babel/runtime']
- }
- }
- : {})
- }
- ]
- ]
- // 复制signalR
- const copy = [
- {
- from: path.join(__dirname, '../node_modules/@aspnet/signalr/dist/browser/signalr.min.js'),
- to: path.join(__dirname, '../dist')
- },
- {
- from: path.join(__dirname, '../node_modules/@aspnet/signalr/dist/browser/signalr.min.js.map'),
- to: path.join(__dirname, '../dist')
- },
- {
- from: path.join(
- __dirname,
- '../node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.signalr-client.js'
- ),
- to: path.join(__dirname, '../dist')
- }
- ]
- export default {
- extraBabelPlugins: [
- // ['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }],
- ['lodash'] // lodash-webpack-plugin
- ],
- history: 'hash',
- hash: true, // 是否开启 hash 文件后缀
- // add for transfer to umi
- plugins,
- targets: {
- ie: 11
- },
- define: {
- BAIDU_MAP_AK: '4CK0UtaFanYgeyVA4RbBNZTS6CFedMgM',
- // QQ_MAP_AK: 'SW7BZ-LY33F-JEXJW-JWNBE-UCEEE-64BPI',
- QQ_MAP_AK: 'I5NBZ-NA2HU-Y62VT-2HYXF-KJLQS-3VBEY',
- APP_TYPE: process.env.APP_TYPE || '',
- APP_BASE_URL: 'http://localhost:8000/',
- REMOTE_SERVICE_BASE_URL: 'http://localhost:21021',
- APP_API_MATERIAL_UPLOAD_URL: 'http://localhost:21021/api/Material/Upload', //这里设置成本地连接才能正确的在后台IM中收发消息
- // APP_API_MATERIAL_UPLOAD_URL: 'http://localhost:21021/api/Material/Upload',
- APP_API_MATERIAL_UPLOAD_PANORAMA_URL: 'http://localhost:21021/api/Material/UploadPanorama',
- APP_API_MATERIAL_UPLOAD_TOPIC_URL: 'http://localhost:21021/api/Material/UploadTopic',
- APP_API_MATERIAL_UPLOAD_VIDEO_URL: 'http://localhost:21021/api/Material/UploadVideo',
- APP_ABP_SIGNALR_CLIENT_JS_URL: `abp.signalr-client.js`,
- APP_AVATAR_IMAGE_URL:
- 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png'
- },
- treeShaking: true,
- // 路由配置
- routes: pageRoutes,
- // Theme for antd
- // https://ant.design/docs/react/customize-theme-cn
- theme: {
- 'primary-color': '#eda92a',
- 'layout-header-height': '40px',
- 'line-height-base': '1',
- 'link-color': '#e89a08',
- 'table-header-sort-active-bg': '#efefef',
- 'table-header-filter-active-bg': '#e0e0e0'
- },
- copy,
- externals: {
- // 'gg-editor': 'GGEditor',
- // react: 'React',
- // 'react-dom': 'ReactDOM',
- // 'react-dom/server': 'ReactDOMServer',
- // 'react-beautiful-dnd': 'ReactBeautifulDnd',
- // '@antv/data-set': 'DataSet',
- // '@antv/g6': 'G6',
- // antd: 'antd',
- // moment: 'moment',
- tinymce: 'tinymce'
- },
- // alias: {
- // // 在 Ant Design (Antd) 中使用 Day.js 替换 Moment
- // // https://github.com/iamkun/dayjs/issues/529
- // moment: 'dayjs',
- // },
- devtool: 'inline-source-map',
- ignoreMomentLocale: true,
- lessLoaderOptions: {
- javascriptEnabled: true
- },
- disableRedirectHoist: true,
- cssLoaderOptions: {
- modules: true,
- getLocalIdent: (context, localIdentName, localName) => {
- if (
- context.resourcePath.includes('node_modules') ||
- context.resourcePath.includes('ant.design.pro.less') ||
- context.resourcePath.includes('global.less') ||
- context.resourcePath.includes('src/layouts/ChatLayout.less') ||
- context.resourcePath.includes('react-contextmenu.less')
- ) {
- return localName
- }
- // const chatMatch = context.resourcePath.match(/src\/pages\/Chat(.*)/i);
- // if (chatMatch && chatMatch[1]) {
- // return localName;
- // }
- // const chatComponents = context.resourcePath.match(/src\/components\/Chat(.*)/i);
- // if (chatComponents && chatComponents[1]) {
- // return localName;
- // }
- //上面的代码windows读取不到路径
- const chatMatch = context.resourcePath.match(/Chat(.*)/)
- if (chatMatch && chatMatch[1]) {
- return localName
- }
- const webImMatch = context.resourcePath.match(/WebIm(.*)/)
- if (webImMatch && webImMatch[1]) {
- return localName
- }
- const match = context.resourcePath.match(/src(.*)/)
- if (match && match[1]) {
- const antdProPath = match[1].replace('.less', '')
- const arr = antdProPath
- .split('/')
- .map(a => a.replace(/([A-Z])/g, '-$1'))
- .map(a => a.toLowerCase())
- return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-')
- }
- return localName
- }
- },
- manifest: {
- basePath: '/'
- },
- chainWebpack: webpackPlugin
- }
|