forked from csstools/react-app-rewire-postcss
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.cjs.js
25 lines (20 loc) · 816 Bytes
/
index.cjs.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
'use strict';
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'));
module.exports = index;
//# sourceMappingURL=index.cjs.js.map