// 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, 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/abp-web-resources/Abp/Framework/scripts/libs/abp.signalr-client.js' ), to: path.join(__dirname, '../dist') } ] // const APP_API_URL = 'http://59.37.167.93:8095'; const base = 'pages' const publicPath = `/` export default { // publicPath, // base, // 指定 react-router 的 base,部署到非根目录时需要配置 // publicPath: `/${APP_BASE}/`, // 指向静态资源的目录 extraBabelPlugins: [ // ['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }], ['lodash'] // lodash-webpack-plugin ], history: 'hash', // add for transfer to umi hash: true, // 是否开启 hash 文件后缀 plugins, targets: { ie: 11 }, define: { BAIDU_MAP_AK: '4CK0UtaFanYgeyVA4RbBNZTS6CFedMgM', QQ_MAP_AK: 'SW7BZ-LY33F-JEXJW-JWNBE-UCEEE-64BPI', APP_TYPE: process.env.APP_TYPE || '', APP_BASE_URL: 'https://muat.zsdhome.cn/', REMOTE_SERVICE_BASE_URL: 'https://portaluat.zsdhome.cn', APP_API_MATERIAL_UPLOAD_URL: 'https://portaluat.zsdhome.cn/api/Material/Upload', APP_API_MATERIAL_UPLOAD_PANORAMA_URL: 'https://portaluat.zsdhome.cn/api/Material/UploadPanorama', APP_API_MATERIAL_UPLOAD_TOPIC_URL: 'https://portaluat.zsdhome.cn/api/Material/UploadTopic', APP_API_MATERIAL_UPLOAD_VIDEO_URL: 'https://portaluat.zsdhome.cn/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': defaultSettings.primaryColor }, copy, externals: { react: 'React', 'react-dom': 'ReactDOM', 'react-dom/server': 'ReactDOMServer', antd: 'antd', moment: 'moment', tinymce: 'tinymce' }, // alias: { // // 在 Ant Design (Antd) 中使用 Day.js 替换 Moment // // https://github.com/iamkun/dayjs/issues/529 // moment: 'dayjs', // }, ignoreMomentLocale: true, lessLoaderOptions: { javascriptEnabled: true }, devtool: false, // 没有关闭source-map disableRedirectHoist: true, disableCSSSourceMap: true, // 禁用 CSS 的 SourceMap 生成 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(/Chat|WebIm(.*)/); 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 }