-
Notifications
You must be signed in to change notification settings - Fork 16
/
craco.config.js
116 lines (113 loc) · 3.19 KB
/
craco.config.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
const CracoLessPlugin = require('craco-less');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const { getLoaders, loaderByName } = require('@craco/craco');
process.env.isEE =
process.argv.includes('--ee') || process.env.NODE_ENV === 'test';
console.log(`current mode: ${process.env.isEE === 'true' ? 'ee' : 'ce'}`);
module.exports = {
webpack: {
plugins: {
add: [
new MonacoWebpackPlugin({
languages: ['sql'],
features: ['smartSelect', 'suggest'],
}),
],
},
configure: (config) => {
const babelLoaders = getLoaders(config, loaderByName('babel-loader'));
if (babelLoaders.hasFoundAny) {
babelLoaders.matches.forEach((item) => {
if (item.loader.test.test('aaa.tsx')) {
const { loader, options } = item.loader;
delete item.loader.loader;
delete item.loader.options;
item.loader.use = [
{
loader,
options,
},
{
loader: 'js-conditional-compile-loader',
options: {
isEE: process.env.isEE === 'true',
isCE: process.env.isEE !== 'true',
},
},
];
}
});
}
return config;
},
},
jest: {
configure: {
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/api/**/*.{ts,tsx}',
'!src/**/*.d.{ts,tsx}',
'!src/**/*.type.{ts,tsx}',
'!src/locale/**/*.{ts,tsx}',
'!src/testUtils/**/*.{ts,tsx}',
'!src/data/**/*.{ts,tsx}',
'!src/reportWebVitals.ts',
'!src/index.tsx',
'!src/router/config.tsx',
'!src/components/BackendForm/index.ts',
'!src/components/EditText/index.ts',
'!src/hooks/useOperation/index.tsx',
'!src/page/AuditPlan/PlanForm/AuditTaskType/index.tsx',
'!src/page/ProjectManage/ProjectOverview/Chats/CommonGauge/registerShape.ts',
'!src/hooks/useMonacoEditor/regexLanguage.ts',
],
moduleNameMapper: {
'react-monaco-editor': '<rootDir>/src/testUtils/mockEditor.jsx',
'@ant-design/plots': '<rootDir>/src/testUtils/mockAntDesignPlots.jsx',
},
},
},
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
javascriptEnabled: true,
},
},
},
},
],
devServer: (config, { proxy }) => {
config.proxy = {
...(function () {
const url = ['/static/media'];
return url.reduce((acc, cur) => {
acc[cur] = {
target: 'http://124.70.158.246:8889',
secure: false,
changeOrigin: true,
ws: true,
xfwd: true,
};
return acc;
}, {});
})(),
...(function () {
const res = {};
for (let i = 0; i < 10; i++) {
res[`/v${i}`] = {
target: 'http://10.186.62.87:10000/',
secure: false,
changeOrigin: true,
ws: true,
xfwd: true,
};
}
return res;
})(),
};
return config;
},
};