-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.umirc.ts
121 lines (115 loc) · 2.8 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
119
120
121
/* tslint:disable */
import path, { resolve } from 'path';
import { IConfig } from 'umi-types';
import pageRoutes from './config/router.config';
import ThemeConfig from './config/theme.config';
import pxToViewPort from 'postcss-px-to-viewport';
import slash from 'slash2';
// ref: https://umijs.org/config/
const config: IConfig = {
treeShaking: true,
history: 'hash',
// 禁用 redirect 上提
disableRedirectHoist: true,
plugins: [
// ref: https://umijs.org/plugin/umi-plugin-react.html
[
'umi-plugin-react',
{
antd: true,
dva: true,
dynamicImport: { webpackChunkName: true },
title: '智能电源控制项目',
dll: false,
routes: {
exclude: [
/public\//,
/models\//,
/services\//,
/model\.(t|j)sx?$/,
/service\.(t|j)sx?$/,
/components\//,
],
},
},
],
],
// 开启hash文件后缀
hash: true,
targets: {
chrome: 30,
},
// 路由配置
routes: pageRoutes,
// Theme for antd
// https://ant.design/docs/react/customize-theme
theme: ThemeConfig('../src/themes/templates/light.less'),
define: {
API_PREFIX: '',
},
alias: {
'@': resolve(__dirname, './src/'),
},
lessLoaderOptions: {
javascriptEnabled: true,
},
cssLoaderOptions: {
modules: true,
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 = slash(antdProPath)
.split('/')
.map((a: string) => a.replace(/([A-Z])/g, '-$1'))
.map((a: string) => a.toLowerCase());
return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
}
return localName;
},
},
extraPostCSSPlugins: [
pxToViewPort({
unitToConvert: 'px',
viewportWidth: 1920,
unitPrecision: 5,
propList: ['*'],
viewportUnit: 'vw',
fontViewportUnit: 'vw',
selectorBlackList: [],
minPixelValue: 1,
mediaQuery: false,
replace: true,
exclude: [/node_modules/],
landscape: false,
landscapeUnit: 'vw',
landscapeWidth: 568,
}),
],
extraBabelPlugins: [
[
'import',
{
libraryName: 'lodash',
libraryDirectory: '',
camel2DashComponentName: false,
},
'lodash',
],
],
// chainWebpack: webpackPlugin,
};
export default config;