Summary
Shakapacker’s generated base config is flexible, but for SSR server bundles we currently need fragile manual rule mutation in app code:
- strip CSS extraction/style loaders
- set
css-loader to exportOnlyLocals
- disable asset emission for file/url loader rules
- force single chunk and node-target output behavior
This pattern is common enough that a first-class helper/API would reduce breakage across loader/plugin updates.
Why This Matters
In a React on Rails Pro + RSC demo, the server config has to iterate through module.rules and mutate internals by loader-name matching. That is brittle when dependencies or defaults evolve.
Suggested Improvement
Provide a supported server/SSR helper mode, for example:
generateWebpackConfig({ target: 'node', ssr: true }), or
- a utility like
applySsrServerBundleDefaults(config).
Expected behavior for the helper:
- preserve CSS module class-name mapping for SSR (
exportOnlyLocals behavior)
- avoid emitting static assets from SSR bundle
- avoid client-only plugins in server bundle
- keep output/private-path conventions compatible with current Shakapacker config
Acceptance Criteria
- Apps can create SSR bundle configs without manually mutating
module.rules internals.
- Helper behavior is covered by tests and documented for both webpack and rspack paths (where supported).
Duplicate Check
I searched for existing SSR helper/API issues and did not find one matching this request.
Related
Summary
Shakapacker’s generated base config is flexible, but for SSR server bundles we currently need fragile manual rule mutation in app code:
css-loadertoexportOnlyLocalsThis pattern is common enough that a first-class helper/API would reduce breakage across loader/plugin updates.
Why This Matters
In a React on Rails Pro + RSC demo, the server config has to iterate through
module.rulesand mutate internals by loader-name matching. That is brittle when dependencies or defaults evolve.Suggested Improvement
Provide a supported server/SSR helper mode, for example:
generateWebpackConfig({ target: 'node', ssr: true }), orapplySsrServerBundleDefaults(config).Expected behavior for the helper:
exportOnlyLocalsbehavior)Acceptance Criteria
module.rulesinternals.Duplicate Check
I searched for existing SSR helper/API issues and did not find one matching this request.
Related