|
| 1 | +// https://umijs.org/config/ |
| 2 | +import os from 'os'; |
| 3 | +import pageRoutes from './router.config'; |
| 4 | + |
| 5 | +const plugins = [ |
| 6 | + [ |
| 7 | + 'umi-plugin-react', |
| 8 | + { |
| 9 | + antd: true, |
| 10 | + dva: { |
| 11 | + hmr: true, |
| 12 | + }, |
| 13 | + targets: { |
| 14 | + ie: 11, |
| 15 | + }, |
| 16 | + locale: { |
| 17 | + enable: true, // default false |
| 18 | + default: 'zh-CN', // default zh-CN |
| 19 | + }, |
| 20 | + dynamicImport: { |
| 21 | + loadingComponent: './components/PageLoading/index', |
| 22 | + }, |
| 23 | + ...(!process.env.TEST && os.platform() === 'darwin' |
| 24 | + ? { |
| 25 | + dll: { |
| 26 | + include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'], |
| 27 | + exclude: ['@babel/runtime'], |
| 28 | + }, |
| 29 | + hardSource: true, |
| 30 | + } |
| 31 | + : {}), |
| 32 | + }, |
| 33 | + ], |
| 34 | +]; |
| 35 | + |
| 36 | +export default { |
| 37 | + // add for transfer to umi |
| 38 | + plugins, |
| 39 | + targets: { |
| 40 | + ie: 11, |
| 41 | + }, |
| 42 | + // 路由配置 |
| 43 | + routes: pageRoutes, |
| 44 | + hash: true, |
| 45 | + // Theme for antd |
| 46 | + // https://ant.design/docs/react/customize-theme-cn |
| 47 | + theme: { |
| 48 | + 'primary-color': '#FA8C16', |
| 49 | + }, |
| 50 | + proxy: { |
| 51 | + '/api/': { |
| 52 | + target: 'http://127.0.0.1:10088/', |
| 53 | + changeOrigin: true, |
| 54 | + }, |
| 55 | + }, |
| 56 | + ignoreMomentLocale: true, |
| 57 | + lessLoaderOptions: { |
| 58 | + javascriptEnabled: true, |
| 59 | + }, |
| 60 | + disableRedirectHoist: true, |
| 61 | + cssLoaderOptions: { |
| 62 | + modules: true, |
| 63 | + getLocalIdent: (context, _, localName) => { |
| 64 | + if ( |
| 65 | + context.resourcePath.includes('node_modules') || |
| 66 | + context.resourcePath.includes('global.less') |
| 67 | + ) { |
| 68 | + return localName; |
| 69 | + } |
| 70 | + const match = context.resourcePath.match(/src(.*)/); |
| 71 | + if (match && match[1]) { |
| 72 | + const antdProPath = match[1].replace('.less', ''); |
| 73 | + const arr = antdProPath |
| 74 | + .split('/') |
| 75 | + .map(a => a.replace(/([A-Z])/g, '-$1')) |
| 76 | + .map(a => a.toLowerCase()); |
| 77 | + return `web${arr.join('-')}-${localName}`.replace(/--/g, '-'); |
| 78 | + } |
| 79 | + return localName; |
| 80 | + }, |
| 81 | + }, |
| 82 | + manifest: { |
| 83 | + basePath: '/', |
| 84 | + }, |
| 85 | +}; |
0 commit comments