// 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 }