Skip to content

Instantly share code, notes, and snippets.

@davidmles
Last active August 4, 2021 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidmles/2e4bbcb4cb43e93e93d0c847a0f3da85 to your computer and use it in GitHub Desktop.
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
// 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