Skip to content

Commit 097a3ba

Browse files
justin808claude
andcommitted
Fix webpack config error with undefined scss rule
The webpack config was failing with "Cannot read properties of undefined (reading 'push')" because the SCSS rule might not exist or might not have a 'use' property in Shakapacker 9.3.0's generated config. Added proper guard check before attempting to push to the scss config's use array. Error was: TypeError: Cannot read properties of undefined (reading 'push') at commonWebpackConfig.js:27:59 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent d39e978 commit 097a3ba

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spec/dummy/config/webpack/commonWebpackConfig.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ const sassLoaderConfig = {
2424
const scssConfigIndex = baseClientWebpackConfig.module.rules.findIndex((config) =>
2525
'.scss'.match(config.test),
2626
);
27-
baseClientWebpackConfig.module.rules[scssConfigIndex]?.use.push(sassLoaderConfig);
27+
if (scssConfigIndex !== -1 && baseClientWebpackConfig.module.rules[scssConfigIndex]?.use) {
28+
baseClientWebpackConfig.module.rules[scssConfigIndex].use.push(sassLoaderConfig);
29+
}
2830

2931
// Configure CSS Modules to use default exports (Shakapacker 9.0 compatibility)
3032
// Shakapacker 9.0 defaults to namedExport: true, but we use default imports

0 commit comments

Comments
 (0)