Skip to content

Commit 4fd1204

Browse files
justin808claude
andcommitted
Fix webpack config to fallback when privateOutputPath is undefined
The generated serverWebpackConfig.js was failing when Shakapacker 9+ was detected but private_output_path wasn't configured in shakapacker.yml. This caused config.privateOutputPath to be undefined, resulting in webpack building to an incorrect location. Changes: - Add fallback to hardcoded path when config.privateOutputPath is undefined - Ensures server bundle is always built to a valid location - Maintains backward compatibility with all Shakapacker versions This fixes the "server-bundle.js cannot be read" error in generator examples. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7e4dd91 commit 4fd1204

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/generators/react_on_rails/templates/base/base/config/webpack/serverWebpackConfig.js.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const configureServer = () => {
5858
globalObject: 'this',
5959
// If using the React on Rails Pro node server renderer, uncomment the next line
6060
// libraryTarget: 'commonjs2',
61-
path: <%= shakapacker_version_9_or_higher? ? 'config.privateOutputPath' : "require('path').resolve(__dirname, '../../ssr-generated')" %>,
61+
path: <%= shakapacker_version_9_or_higher? ? "config.privateOutputPath || require('path').resolve(__dirname, '../../ssr-generated')" : "require('path').resolve(__dirname, '../../ssr-generated')" %>,
6262
// No publicPath needed since server bundles are not served via web
6363
// https://webpack.js.org/configuration/output/#outputglobalobject
6464
};

0 commit comments

Comments
 (0)