-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.umirc.js
282 lines (268 loc) · 8.75 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
const buildTarget =
(process.env.NODE_ENV === 'production' ? process.env.OJ3_BUILD4 : '') || 'release';
console.log('Using build target:', buildTarget);
console.log('Using COMPETITION_SIDE:', process.env.COMPETITION_SIDE === '1');
process.env.CDN_URL && console.log('Using CDN_URL:', process.env.CDN_URL);
process.env.MEDIA_URL && console.log('Using MEDIA_URL:', process.env.MEDIA_URL);
process.env.CDN_RAW_URL_BEFORE_PROXY && console.log('Using CDN_RAW_URL_BEFORE_PROXY:', process.env.CDN_RAW_URL_BEFORE_PROXY);
process.env.CDN_PROXY && console.log('Using CDN_PROXY:', process.env.CDN_PROXY);
const publicPathPrefix = process.env.CDN_URL || '';
const buildConfig = {
release: {
base: '/onlinejudge3/',
publicPath: `${publicPathPrefix}/onlinejudge3/`,
outputPath: './onlinejudge3',
},
release_competition_side: {
base: '/onlinejudge3_cs/',
publicPath: `${publicPathPrefix}/onlinejudge3_cs/`,
outputPath: './onlinejudge3_cs',
},
// exp: {
// base: '/onlinejudge3_exp/',
// publicPath: `${publicPathPrefix}/onlinejudge3_exp/`,
// outputPath: './onlinejudge3_exp',
// },
// test: {
// base: '/onlinejudge3_test/',
// publicPath: `${publicPathPrefix}/onlinejudge3_test/`,
// outputPath: './onlinejudge3_test',
// },
};
const usingBuildConfig = buildConfig[buildTarget];
const usingPublicPath = usingBuildConfig.publicPath;
export default {
...usingBuildConfig,
hash: true,
define: {
'process.env.COMPETITION_SIDE': process.env.COMPETITION_SIDE === '1' ? '1' : '',
'process.env.BASE': usingBuildConfig.base || '/',
'process.env.CDN_URL': process.env.CDN_URL || '',
'process.env.MEDIA_URL': process.env.MEDIA_URL || '',
'process.env.CDN_RAW_URL_BEFORE_PROXY': process.env.CDN_RAW_URL_BEFORE_PROXY || '',
'process.env.CDN_PROXY': process.env.CDN_PROXY || '',
'process.env.PUBLIC_PATH': process.env.NODE_ENV === 'production' ? usingPublicPath : '/',
'process.env.DATA_USING_GIT': process.env.DATA_USING_GIT === '1',
},
plugins: [
[
'umi-plugin-react',
{
dva: {
immer: true,
},
antd: true,
routes: {
exclude: [/models\//, /services\//],
},
title: {
defaultTitle: 'SDUT OnlineJudge',
separator: '|',
format: '{current} {separator} {parent}',
},
dynamicImport: null,
chunks: [
'vendors',
'raincloud',
'ui',
'time-is-money',
'talk-is-cheap',
'mathematics-is-the-queen-of-the-sciences',
'ms-excel-suite-2022-customized-for-sdut_powered-by-ms-cn',
'draw-some-higher-dimensions-shapes',
'of-all-that-has-been-written_i-love-only-that-which-was-written-in-blood',
'umi',
],
},
],
],
theme: {
// 'primary-color': '#1e66d5', // dark
'btn-border-radius-base': '100px',
'btn-border-radius-sm': '100px',
'success-color': '#4fb24f',
'error-color': '#e23a36',
'icon-url': '"/assets/fonts/iconfont"',
'text-color': 'rgba(0, 0, 0, 0.75)',
'code-family':
'Monaco, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace',
},
proxy: {
'/onlinejudge3/api/': {
target: 'http://127.0.0.1:7001/',
changeOrigin: true,
pathRewrite: { '^/onlinejudge3/api/': '' },
},
'/image/': {
target: 'http://127.0.0.1:7001/public/sf/',
// target: 'https://acm.sdut.edu.cn/image/',
changeOrigin: true,
pathRewrite: {
'^/image/': '',
},
},
},
urlLoaderExcludes: [/\.svg$/],
chainWebpack(config) {
config.module
.rule('svg')
.test(/\.svg(\?v=\d+\.\d+\.\d+)?$/)
.use([
{
loader: 'babel-loader',
},
{
loader: '@svgr/webpack',
options: {
babel: false,
icon: true,
},
},
])
.loader(require.resolve('@svgr/webpack'));
config.optimization.splitChunks({
// chunks: 'async',
// minSize: 30000,
// maxSize: 0,
// minChunks: 1,
maxAsyncRequests: 15,
maxInitialRequests: 15,
// automaticNameDelimiter: '.',
// name: true,
cacheGroups: {
vendors: {
name: 'vendors',
chunks: 'all',
test({ resource }) {
return /[\\/]node_modules[\\/]/.test(resource);
},
priority: 10,
},
raincloud: {
name: 'raincloud',
chunks: 'all',
test: /[\\/]node_modules[\\/](react|react-dom|react-router|react-router-dom|axios|lodash|immutable)[\\/]/,
minSize: 0,
minChunks: 1,
priority: 100,
},
antd: {
name: 'ui',
chunks: 'all',
test: /[\\/]node_modules[\\/](@ant-design|antd)[\\/]/,
minSize: 0,
minChunks: 1,
priority: 100,
},
moment: {
name: 'time-is-money',
chunks: 'all',
test: /[\\/]node_modules[\\/](moment)[\\/]/,
minSize: 0,
minChunks: 1,
priority: 100,
},
highlight: {
name: 'talk-is-cheap',
chunks: 'all',
test: /[\\/]node_modules[\\/](highlight\.js)[\\/]/,
minSize: 0,
minChunks: 1,
priority: 100,
},
katex: {
name: 'mathematics-is-the-queen-of-the-sciences',
chunks: 'all',
test: /[\\/]node_modules[\\/](katex)[\\/]/,
minSize: 0,
minChunks: 1,
priority: 100,
},
xlsx: {
name: 'ms-excel-suite-2022-customized-for-sdut_powered-by-ms-cn',
chunks: 'all',
test: /[\\/]node_modules[\\/](xlsx)[\\/]/,
minSize: 0,
minChunks: 1,
priority: 100,
},
highcharts: {
name: 'draw-some-higher-dimensions-shapes',
chunks: 'all',
test: /[\\/]node_modules[\\/](highcharts)[\\/]/,
minSize: 0,
minChunks: 1,
priority: 100,
},
braftEditor: {
name: 'of-all-that-has-been-written_i-love-only-that-which-was-written-in-blood',
chunks: 'all',
test: /[\\/]node_modules[\\/](braft(-|\w+)(\w*)|draft(-|\w+)(\w*))[\\/]/,
minSize: 0,
minChunks: 1,
priority: 100,
},
// 'async-commons': {
// chunks: 'async',
// minChunks: 2,
// name: 'async-commons',
// priority: 90,
// },
},
});
config.plugin('error-handling-plugin').use(class ErrorHandlingPlugin {
apply(compiler) {
// 编译失败时的错误
compiler.hooks.failed.tap('ErrorHandlingPlugin', (error) => {
console.error('Compiler failed:', error);
});
// 编译阶段的错误
compiler.hooks.compilation.tap('ErrorHandlingPlugin', (compilation) => {
// 模块构建失败的错误
compilation.hooks.buildModule.tap('ErrorHandlingPlugin', (module) => {
// 可以在这里处理模块构建阶段的错误
});
// 优化阶段的错误
compilation.hooks.optimize.tap('ErrorHandlingPlugin', () => {
// 可以在这里处理优化阶段的错误
});
// 处理资源生成阶段的错误
compilation.hooks.afterSeal.tap('ErrorHandlingPlugin', () => {
// 可以在这里处理资源生成阶段的错误
});
// 处理编译过程中的错误
compilation.hooks.afterOptimizeAssets.tap('ErrorHandlingPlugin', (assets) => {
// 可以在这里处理优化资源后的错误
});
// 处理编译过程中的警告
compilation.hooks.afterOptimizeAssets.tap('ErrorHandlingPlugin', (assets) => {
compilation.warnings.forEach((warning) => {
// console.warn('Compilation warning:', warning);
});
});
// 处理编译过程中的错误
compilation.hooks.afterOptimizeAssets.tap('ErrorHandlingPlugin', (assets) => {
compilation.errors.forEach((error) => {
console.error('Compilation error:', error);
});
});
});
// 编译完成时的错误
compiler.hooks.done.tap('ErrorHandlingPlugin', (stats) => {
if (stats.hasErrors()) {
console.error('Compilation completed with errors:');
stats.toJson().errors.forEach((err) => {
console.error(err);
});
}
if (stats.hasWarnings()) {
// console.warn('Compilation completed with warnings:');
// stats.toJson().warnings.forEach((warning) => {
// console.warn(warning);
// });
}
});
}
});
},
};