-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig-overrides.js
32 lines (27 loc) · 960 Bytes
/
config-overrides.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
module.exports = function override(config, env) {
const babelLoaderFilter = rule => {
return rule.loader && rule.loader.includes('babel-loader');
};
// get the babel loader
const babelLoader = config.module.rules.find(babelLoaderFilter);
if (!babelLoader) {
// find the array of rules from oneOf property
const rules = config.module.rules.find(rule => Boolean(rule.oneOf)).oneOf;
// find the babel loader within these rules
const babelRule = rules.find(babelLoaderFilter);
if (babelRule) {
// Modify it to add the decorators plugin
babelRule.options.plugins = [
...babelRule.options.plugins,
["@babel/plugin-proposal-decorators", { "legacy": true }]
];
}
} else {
// Modify the top level loader if it exists
babelLoader.options.plugins = [
...babelLoader.options.plugins,
["@babel/plugin-proposal-decorators", { "legacy": true }]
];
}
return config;
};