Skip to content

Commit 3fe61f0

Browse files
justin808claude
andcommitted
Fix CSS modules config for server bundle
Preserve namedExport and exportLocalsConvention settings when adding exportOnlyLocals for SSR. This prevents CSS module imports from being undefined in the server-rendered bundle. The previous code was replacing the entire modules object, which broke the namedExport configuration required by Shakapacker 9. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5d85f15 commit 3fe61f0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

config/rspack/serverRspackConfig.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,12 @@ const configureServer = () => {
9292

9393
return testValue.includes('css-loader');
9494
});
95-
if (cssLoader && cssLoader.options) {
96-
cssLoader.options.modules = { exportOnlyLocals: true };
95+
if (cssLoader && cssLoader.options && cssLoader.options.modules) {
96+
// Preserve existing modules config but add exportOnlyLocals for SSR
97+
cssLoader.options.modules = {
98+
...cssLoader.options.modules,
99+
exportOnlyLocals: true,
100+
};
97101
}
98102

99103
// Skip writing image files during SSR by setting emitFile to false

0 commit comments

Comments
 (0)