Skip to content

Commit db54f37

Browse files
justin808claude
andcommitted
Move SSR server bundle to private directory
- Configure webpack to output server bundle to app/assets/builds - Update React on Rails config to use new server bundle location - Add app/assets/builds to .gitignore to keep server bundles private - Server bundles are now isolated from public webpack output This follows React on Rails 16 best practices for server-side rendering by keeping server bundles in a private directory separate from client assets. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a9bfe7c commit db54f37

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ vendor/bundle
3131
# Generated js bundles
3232
/public/packs
3333
/public/packs-test
34+
/app/assets/builds
3435

3536
# Rubymine/IntelliJ
3637
.idea

config/initializers/react_on_rails.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# If you are never using server rendering, you may set this to "".
1313
# If you are using the same file for client and server rendering, having this set probably does
1414
# not affect performance.
15-
config.server_bundle_js_file = "server-bundle.js"
15+
config.server_bundle_js_file = "app/assets/builds/server-bundle.js"
1616

1717
# React on Rails 16 compatibility: Workaround for removed error handling
1818
#

config/webpack/serverWebpackConfig.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ const configureServer = () => {
4545

4646
// Custom output for the server-bundle that matches the config in
4747
// config/initializers/react_on_rails.rb
48+
const path = require('path');
4849
serverWebpackConfig.output = {
4950
filename: 'server-bundle.js',
5051
globalObject: 'this',
5152
// If using the React on Rails Pro node server renderer, uncomment the next line
5253
// libraryTarget: 'commonjs2',
53-
path: config.outputPath,
54+
path: path.resolve(__dirname, '../../app/assets/builds'),
5455
publicPath: config.publicPath,
5556
// https://webpack.js.org/configuration/output/#outputglobalobject
5657
};

0 commit comments

Comments
 (0)