-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.umirc.ts
118 lines (115 loc) · 3.14 KB
/
.umirc.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { join } from 'path';
import { defineConfig, utils } from 'umi';
import defaultSetting from './config/defaultSettings';
// import AntdDayjsWebpackPlugin from 'antd-dayjs-webpack-plugin';
// import slash from 'slash2';
// import themePluginConfig from './themePluginConfig';
import proxy from './config/proxy';
import routes from './config/routes';
import themeConfig from './config/theme.config';
import { VALIDATE_MESSAGES } from './src/constants';
const { UMI_ENV = 'dev' } = process.env;
const { winPath } = utils;
export default defineConfig({
favicon: '/favicon.ico',
runtimePublicPath: true,
history: {
type: 'browser',
},
hash: true,
antd: {
// dark: true,
// compact: true,
config: {
form: { validateMessages: VALIDATE_MESSAGES },
input: {
autoComplete: 'off',
},
},
},
request: false,
layout: {
logo: defaultSetting.logo,
title: defaultSetting.title,
theme: defaultSetting.navTheme,
iconfontUrl: defaultSetting.iconfontUrl,
locale: false, // 不启用菜单的多语言
siderWidth: 208,
},
dva: {
immer: true,
hmr: true,
},
locale: {
default: 'zh-CN',
antd: true,
// default true, when it is true, will use `navigator.language` overwrite default
baseNavigator: true,
},
dynamicImport: {
loading: '@ant-design/pro-layout/es/PageLoading',
},
ignoreMomentLocale: true,
targets: {
ie: 11,
},
esbuild: {},
fastRefresh: {},
routes,
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
theme: themeConfig,
alias: {
themes: join(__dirname, './src/themes'),
'@config': join(__dirname, './config'),
'@modules': join(__dirname, './src/modules'),
},
lessLoader: {
javascriptEnabled: true,
},
cssLoader: {
// 这里的 modules 可以接受 getLocalIdent
modules: {
getLocalIdent: (
context: {
resourcePath: string;
},
_: string,
localName: string,
) => {
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 = winPath(antdProPath)
.split('/')
.map((a: string) => a.replace(/([A-Z])/g, '-$1'))
.map((a: string) => a.toLowerCase());
return `wt-site${arr.join('-')}-${localName}`.replace(/--/g, '-');
}
return localName;
},
},
},
manifest: {
basePath: '/',
},
proxy: proxy[UMI_ENV],
// plugins: [new AntdDayjsWebpackPlugin()],
// 配置具体含义见:https://github.com/umijs/umi-webpack-bundle-analyzer#options-for-plugin
analyze: {
analyzerMode: 'server',
analyzerPort: 8888,
openAnalyzer: true,
// generate stats file while ANALYZE_DUMP exist
generateStatsFile: false,
statsFilename: 'stats.json',
logLevel: 'info',
defaultSizes: 'parsed', // stat // gzip
},
});