forked from csstools/react-app-rewire-postcss
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.es.mjs
23 lines (19 loc) · 799 Bytes
/
index.es.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var index = (config, options) => {
// find any first matching rule that contains postcss-loader
filterPostCSSLoader(config.module.rules).forEach(rule => {
filterPostCSSLoader(rule.oneOf).forEach(oneOf => {
filterPostCSSLoader(oneOf.use || oneOf.loader).forEach(use => {
// use the latest version of postcss-loader
use.loader = require.resolve('postcss-loader');
// conditionally replace options with a custom configuration
use.options = options ? options : use.options;
});
});
});
// return the mutated configuration
return config;
};
// return a filtered array that includes postcss-loader
const filterPostCSSLoader = array => array.filter(object => JSON.stringify(object).includes('postcss-loader'));
export default index;
//# sourceMappingURL=index.es.mjs.map