Last active
August 4, 2021 09:29
-
-
Save davidmles/2e4bbcb4cb43e93e93d0c847a0f3da85 to your computer and use it in GitHub Desktop.
environment.js file with a hack to load PostCSS 8 with Webpacker 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/rails/webpacker/issues/2784#issuecomment-737003955 | |
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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment