-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcraco.config.js
43 lines (41 loc) · 1.43 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
const path = require('path');
module.exports = {
webpack: {
alias: {
'@ENV': path.resolve(__dirname, 'src/envs/index.ts'),
},
},
plugins: [
{
plugin: {
overrideWebpackConfig: ({webpackConfig}) => {
const oneOfRule = webpackConfig.module.rules.find((rule) => rule.oneOf);
if (oneOfRule) {
const tsxRule = oneOfRule.oneOf.find(
(rule) => rule.test && rule.test.toString().includes('tsx'),
);
const newIncludePaths = [
// relative path to my yarn workspace library
// path.resolve(__dirname, '../shared/types/'),
// path.resolve(__dirname, '../shared/repositories/'),
// path.resolve(__dirname, '../shared/envs/'),
// path.resolve(__dirname, '../shared/assets/'),
// path.resolve(__dirname, '../shared/charts/'),
// path.resolve(__dirname, '../shared/util/'),
// path.resolve(__dirname, '../shared/const/'),
// path.resolve(__dirname, '../shared/models/'),
];
if (tsxRule) {
if (Array.isArray(tsxRule.include)) {
tsxRule.include = [...tsxRule.include, ...newIncludePaths];
} else {
tsxRule.include = [tsxRule.include, ...newIncludePaths];
}
}
}
return webpackConfig;
},
},
},
],
};