Skip to content

Commit 3414c4d

Browse files
justin808claude
andcommitted
Update documentation for Shakapacker 9.0+ private_output_path integration
Documents the recommended approach of using Shakapacker 9.0+ private_output_path for server bundle configuration, providing a single source of truth. **Documentation Updates:** **1. Configuration API Reference (docs/api-reference/configuration.md)** - Added prominent recommendation for Shakapacker 9.0+ approach - Documents shakapacker.yml private_output_path configuration - Explains auto-detection behavior - Preserves documentation for older versions **2. Webpack Configuration Guide (docs/core-concepts/webpack-configuration.md)** - New section: "Server Bundle Configuration (Shakapacker 9.0+)" - Complete example with shakapacker.yml and webpack config - Lists benefits of the new approach: - Single source of truth - Automatic synchronization - No configuration duplication - Better maintainability - Notes compatibility with older versions **Key Points:** - Shakapacker 9.0+ users get automatic configuration - Backward compatible with manual configuration - Generator templates already show both approaches - Doctor command guides users to upgrade **Related Changes:** - Generator templates already updated in previous commit - Auto-detection implemented in configuration.rb - Doctor provides version-aware recommendations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent bafac33 commit 3414c4d

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

docs/api-reference/configuration.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ ReactOnRails.configure do |config|
126126
# SERVER BUNDLE SECURITY AND ORGANIZATION
127127
################################################################################
128128

129+
# ⚠️ RECOMMENDED: Use Shakapacker 9.0+ for Automatic Configuration
130+
#
131+
# For Shakapacker 9.0+, add to config/shakapacker.yml:
132+
# private_output_path: ssr-generated
133+
#
134+
# React on Rails will automatically detect and use this value, eliminating the need
135+
# to configure server_bundle_output_path here. This provides a single source of truth.
136+
#
137+
# For older Shakapacker versions or custom setups, manually configure:
129138
# This configures the directory (relative to the Rails root) where the server bundle will be output.
130139
# By default, this is "ssr-generated". If set to nil, the server bundle will be loaded from the same
131140
# public directory as client bundles. For enhanced security, use this option in conjunction with

docs/core-concepts/webpack-configuration.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,38 @@ default: &default
7878
7979
The `bin/switch-bundler` script automatically updates this configuration when switching bundlers.
8080

81+
### Server Bundle Configuration (Shakapacker 9.0+)
82+
83+
**Recommended**: For Shakapacker 9.0+, use `private_output_path` in `shakapacker.yml` for server bundles:
84+
85+
```yaml
86+
default: &default # ... other config ...
87+
private_output_path: ssr-generated
88+
```
89+
90+
This provides a single source of truth for server bundle location. React on Rails automatically detects this configuration, eliminating the need to set `server_bundle_output_path` in your React on Rails initializer.
91+
92+
In your `config/webpack/serverWebpackConfig.js`:
93+
94+
```javascript
95+
const { config } = require('shakapacker');
96+
97+
serverWebpackConfig.output = {
98+
filename: 'server-bundle.js',
99+
globalObject: 'this',
100+
path: config.privateOutputPath, // Automatically uses shakapacker.yml value
101+
};
102+
```
103+
104+
**Benefits:**
105+
106+
- Single source of truth in `shakapacker.yml`
107+
- Automatic synchronization between webpack and React on Rails
108+
- No configuration duplication
109+
- Better maintainability
110+
111+
**For older Shakapacker versions:** Use hardcoded paths and manual configuration as shown in the generator templates.
112+
81113
Per the example repo [shakacode/react_on_rails_demo_ssr_hmr](https://github.com/shakacode/react_on_rails_demo_ssr_hmr),
82114
you should consider keeping your codebase mostly consistent with the defaults for [Shakapacker](https://github.com/shakacode/shakapacker).
83115

0 commit comments

Comments
 (0)