-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcssPatch.js
25 lines (23 loc) · 957 Bytes
/
cssPatch.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
const {findRules} = require('./utils')
module.exports.cssPatch = function cssPatch(webpackConfig, isDevelopment) {
const cssRules = findRules(webpackConfig, (rule) => {
return (
'' + rule.test === '' + /\.css$/ ||
'' + rule.test === '' + /\.module\.css$/ ||
'' + rule.test === '' + /\.(scss|sass)$/ ||
'' + rule.test === '' + /\.module\.(scss|sass)$/
)
});
cssRules.forEach((cssRule) => {
const cssLoaders = isDevelopment ? cssRule.use : cssRule.loader
cssLoaders.forEach((loader) => {
if (loader.options && loader.options.ident === 'postcss') {
const postCssLoader = loader
const postCssFunction = postCssLoader.options.plugins
postCssLoader.options.plugins = () => {
return [...postCssFunction(), require('postcss-inline-rtl')]
}
}
});
});
}