import defaultSettings from './defaultSettings'; // https://umijs.org/config/ import { chainWebpack } from './plugin.config' import slash from 'slash2'; import themePluginConfig from './themePluginConfig'; const { pwa } = defaultSettings; // preview.pro.ant.design only do not use in your production ; // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 import { routerConfig } from './routerConfig.js'; const autoprefixer = require('autoprefixer') const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env; const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site'; const plugins = [ [ 'umi-plugin-react', { antd: true, dva: { hmr: true, }, locale: { enable: true, default: 'zh-CN', baseNavigator: true, }, // dynamicImport: { // loadingComponent: './components/PageLoading/index', // webpackChunkName: true, // level: 3, // }, pwa: pwa ? { workboxPluginMode: 'InjectManifest', workboxOptions: { importWorkboxFrom: 'local', }, } : false, // default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665 headScripts: [ // 'https://cdn.bootcss.com/react/16.8.6/umd/react.production.min.js', // 'https://cdn.bootcss.com/react-dom/16.8.6/umd/react-dom.production.min.js', // 'https://cdn.bootcss.com/moment.js/2.24.0/moment.min.js', // 'https://cdn.bootcss.com/moment.js/2.24.0/locale/zh-cn.js', // 'https://cdn.bootcss.com/antd/3.26.2/antd.min.js', // 'https://cdn.bootcss.com/echarts/4.6.0/echarts.min.js', 'http://sp.qn.timichat.com/assets/AgoraRTCSDK/3.0.2/AgoraRTCSDK-3.0.2.js' ], // links: [{ // href: 'https://cdn.bootcss.com/antd/3.26.2/antd.min.css', rel: 'stylesheet', type: 'text/css' // }] }, ], [ 'umi-plugin-pro-block', { moveMock: false, moveService: false, modifyRequest: true, autoAddMenu: true, }, ] ]; if (isAntDesignProPreview) { // 针对 preview.pro.ant.design 的 GA 统计代码 plugins.push([ 'umi-plugin-ga', { code: 'UA-72788897-6', }, ]); plugins.push(['umi-plugin-antd-theme', themePluginConfig]); } export default { plugins, hash: true, targets: { ie: 9, }, routes: routerConfig, // Theme for antd: https://ant.design/docs/react/customize-theme-cn theme: { // ...darkTheme, 'primary-color': '#ff4d5c', }, define: { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 }, ignoreMomentLocale: true, lessLoaderOptions: { javascriptEnabled: true, }, disableRedirectHoist: true, cssLoaderOptions: { modules: true, getLocalIdent: (context, _, localName) => { if ( context.resourcePath.includes('node_modules') || context.resourcePath.includes('ant.design.pro.less') || context.resourcePath.includes('global.less') ) { return localName; } const match = context.resourcePath.match(/src(.*)/); if (match && match[1]) { const antdProPath = match[1].replace('.less', ''); const arr = slash(antdProPath) .split('/') .map(a => a.replace(/([A-Z])/g, '-$1')) .map(a => a.toLowerCase()); return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-'); } return localName; }, }, extraPostCSSPlugins: [ autoprefixer({ flexbox: true }) ], manifest: { basePath: '/', }, // chainWebpack: chainWebpack, proxy: { '/api-manage': { target: 'http://api.timichat.net', changeOrigin: true, //pathRewrite: { '^/server': '' }, }, '/api-common': { target: 'http://api.timichat.net', changeOrigin: true, //pathRewrite: { '^/server': '' }, }, '/rongcloud': { target: 'http://message.ronghub.com', changeOrigin: true, pathRewrite: { '^/rongcloud': '' }, } }, treeShaking: true, mock: { exclude: [], }, publicPath: '/', // outputPath: './manage', };