Fix postcss-loader config

The configuration keys have some issues across different versions of postcss
This commit is contained in:
Matt-Yorkley
2021-12-07 14:28:09 +00:00
parent afd381cbad
commit 09b9c3d4d0

View File

@@ -1,3 +1,23 @@
const { environment } = require('@rails/webpacker')
module.exports = environment
function hotfixPostcssLoaderConfig (subloader) {
const subloaderName = subloader.loader
if (subloaderName === 'postcss-loader') {
if (subloader.options.postcssOptions) {
console.log(
'\x1b[31m%s\x1b[0m',
'Remove postcssOptions workaround in config/webpack/environment.js'
)
} else {
subloader.options.postcssOptions = subloader.options.config;
delete subloader.options.config;
}
}
}
environment.loaders.keys().forEach(loaderName => {
const loader = environment.loaders.get(loaderName);
loader.use.forEach(hotfixPostcssLoaderConfig);
});