-
Notifications
You must be signed in to change notification settings - Fork 2
/
.umirc.js
76 lines (69 loc) · 1.71 KB
/
.umirc.js
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
const pkg = require('./package.json');
const { BUILD_DOC_VERSION } = process.env;
const MajorVersionNumber = pkg.version.split('.')[0];
const versionSiteRoot = `refs/heads/v${MajorVersionNumber}`;
const version = BUILD_DOC_VERSION ? versionSiteRoot : 'latest';
const isDev = process.env.NODE_ENV === 'development';
const serverRootDirect = !isDev ? '/rc-hooks/' : '/';
const outputPath = 'site';
const publicPath = serverRootDirect + version + '/';
const logo = 'https://doly-dev.github.io/logo.png';
const favicon = 'https://doly-dev.github.io/favicon.png';
const umiConfig = {
mode: 'doc',
history: {
type: 'hash'
},
title: pkg.name,
logo,
favicon,
publicPath,
outputPath,
hash: true,
locales: [
['zh-CN', '中文'],
['en-US', 'English']
],
// esbuild: !isDev,
nodeModulesTransform: {
type: isDev ? 'none' : 'all'
},
targets: {
ie: 11
},
polyfill: {
imports: ['element-remove', 'core-js']
}
};
if (!isDev) {
umiConfig.headScripts = [
{ src: 'https://www.googletagmanager.com/gtag/js?id=G-P755RQJZZ2', async: true },
{
content: `window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-P755RQJZZ2');
`
}
];
umiConfig.chunks = ['vendors', 'umi'];
umiConfig.chainWebpack = function (config, { webpack }) {
config.merge({
optimization: {
minimize: true,
splitChunks: {
cacheGroups: {
vendor: {
test: /node_modules/,
chunks: 'all',
name: 'vendors',
priority: -10,
enforce: true
}
}
}
}
});
};
}
export default umiConfig;