forked from YaoApp/xgen-deprecated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.umirc.ts
131 lines (114 loc) · 2.96 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
122
123
124
125
126
127
128
129
130
131
import { resolve } from 'path'
import { defineConfig } from 'umi'
import WebpackPwaManifest from 'webpack-pwa-manifest'
import OfflinePlugin from '@lcdp/offline-plugin'
import config from './config'
import theme from './src/theme'
import type { BaseIConfig } from 'umi'
const env = process.env.NODE_ENV as 'development' | 'production'
const getLinks = () => {
const arr = [{ rel: 'stylesheet', href: `${config.base}icon/md_icon.css` }]
if (env === 'production' && config.pwa)
arr.push({ rel: 'manifest', href: `${config.base}manifest.json` })
return arr
}
const getScripts = () => {
const arr = []
if (config.oss) arr.push('https://gosspublic.alicdn.com/aliyun-oss-sdk-6.16.0.min.js')
return arr
}
const links = getLinks()
const scripts = getScripts()
const other_config: BaseIConfig = {}
if (process.env.APP_ENV === 'development') {
other_config['devtool'] = 'source-map'
}
export default defineConfig({
theme,
links,
scripts,
antd: {},
mock: {},
hash: true,
cssnano: {},
webpack5: {},
fastRefresh: {},
base: config.base,
title: config.name,
publicPath: config.base,
cssModulesTypescriptLoader: {},
dva: { immer: true, hmr: true },
nodeModulesTransform: { type: 'none' },
alias: { R: resolve(__dirname, './') },
dynamicImport: { loading: '@/components/Loader/index' },
locale: { default: 'zh-CN', antd: true, baseNavigator: true },
chainWebpack(cfg: any) {
cfg.resolve.alias.set('moment$', resolve(__dirname, 'node_modules/moment/moment.js'))
cfg.module.rule('mjs-rule').test(/.m?js/).resolve.set('fullySpecified', false)
if (env === 'production') {
cfg.merge({
optimization: {
splitChunks: {
chunks: 'all',
minSize: 30000,
minChunks: 3,
automaticNameDelimiter: '.',
cacheGroups: {
vendor: {
name: 'vendors',
test({ resource }: any) {
return /[\\/]node_modules[\\/]/.test(resource)
},
priority: 10
}
}
}
}
})
if (config.pwa) {
cfg.plugin('offline-plugin').use(OfflinePlugin, [webpack_plugin_offline])
cfg.plugin('webpack-pwa-manifest').use(WebpackPwaManifest, [
webpack_plugin_pwa
])
}
}
},
proxy: {
'/api': {
target: 'http://local.iqka.com:5099',
changeOrigin: true
},
'/extend': {
target: 'http://local.iqka.com:5099',
changeOrigin: true
},
'/assets': {
target: 'http://local.iqka.com:5099',
changeOrigin: true
}
},
...other_config
})
const webpack_plugin_offline: any = {
updateStrategy: 'changed',
autoUpdate: 1000 * 60 * 2,
safeToUseOptionalCaches: true,
AppCache: { events: true },
ServiceWorker: { events: true, navigateFallbackURL: '/' }
}
const webpack_plugin_pwa: any = {
name: config.name,
short_name: config.short_name,
fingerprints: false,
description: config.description,
background_color: '#232326',
theme_color: '#40b983',
crossorigin: 'use-credentials',
display: 'standalone',
icons: [
{
src: resolve('public/logo.png'),
sizes: [96, 128, 192, 256, 384, 512]
}
]
}