-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
35 lines (34 loc) · 1.04 KB
/
webpack.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
const util = require('util');
module.exports.getWebpackConfig = (config, options) => {
// removes all 'data-test' attributes from React components - only 'remove-object-properties' worked, so if any lib need 'data-test', bad luck :S
if (options.production) {
const rulesWithBabelLoader = config.module.rules.filter(x => {
if (x.loaders) {
return x.loaders.some(loader => loader.loader === 'babel-loader');
}
return false;
});
const patchedBabelRules = rulesWithBabelLoader.map(rule => ({
...rule,
loaders: rule.loaders.map(loader => ({
...loader,
options: {
...loader.options,
...(loader.options.plugins
? {
plugins: [...loader.options.plugins, ['remove-object-properties', { regexp: 'data-test' }]],
}
: {}),
},
})),
}));
return {
...config,
module: {
...config.module,
rules: [...config.module.rules, ...patchedBabelRules],
},
};
}
return config;
};