Skip to content

Commit 895bea8

Browse files
justin808claude
andcommitted
Update Pro dummy webpack config to use forEach pattern
The findIndex approach with '.scss'.match(config.test) was failing in Shakapacker 9.1.0 because the webpack rule structure changed. Updated Pro dummy to use the same forEach pattern as main dummy: - Tests both 'example.scss' and 'example.module.scss' - Safely checks if rule.use is an array before pushing - Handles both regular SCSS and CSS Module SCSS files This fixes the build error: "TypeError: Cannot read properties of undefined (reading 'push')" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e3366cb commit 895bea8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

react_on_rails_pro/spec/dummy/config/webpack/commonWebpackConfig.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ const sassLoaderConfig = {
2626
};
2727

2828
const baseClientWebpackConfig = generateWebpackConfig();
29-
const scssConfigIndex = baseClientWebpackConfig.module.rules.findIndex((config) =>
30-
'.scss'.match(config.test),
31-
);
32-
baseClientWebpackConfig.module.rules[scssConfigIndex].use.push(sassLoaderConfig);
29+
30+
// Add sass-resources-loader to all SCSS rules (both .scss and .module.scss)
31+
baseClientWebpackConfig.module.rules.forEach((rule) => {
32+
if (Array.isArray(rule.use) && rule.test && (rule.test.test('example.scss') || rule.test.test('example.module.scss'))) {
33+
rule.use.push(sassLoaderConfig);
34+
}
35+
});
3336

3437
if (isHMR) {
3538
baseClientWebpackConfig.plugins.push(

0 commit comments

Comments
 (0)