Skip to content

Commit f96bbed

Browse files
committed
Hotfix PostCSS loader incompatibility
We were seeing Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema. options has an unknown property 'config'. These properties are valid: object { postcssOptions?, execute?, sourceMap? } This patch seems to fix it rails/webpacker#2784 at least until we can upgrade properly.
1 parent bf7e986 commit f96bbed

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

config/webpack/environment.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
const { environment } = require('@rails/webpacker')
22

3+
function hotfixPostcssLoaderConfig (subloader) {
4+
const subloaderName = subloader.loader
5+
if (subloaderName === 'postcss-loader') {
6+
if (subloader.options.postcssOptions) {
7+
console.log(
8+
'\x1b[31m%s\x1b[0m',
9+
'Remove postcssOptions workaround in config/webpack/environment.js'
10+
)
11+
} else {
12+
subloader.options.postcssOptions = subloader.options.config;
13+
delete subloader.options.config;
14+
}
15+
}
16+
}
17+
18+
environment.loaders.keys().forEach(loaderName => {
19+
const loader = environment.loaders.get(loaderName);
20+
loader.use.forEach(hotfixPostcssLoaderConfig);
21+
});
22+
323
module.exports = environment

0 commit comments

Comments
 (0)