You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 <noreply@anthropic.com>
# When set to true, React on Rails will only load server bundles from private, explicitly configured directories (such as `ssr-generated`), and will raise an error if a server bundle is found in a public or untrusted location. This helps prevent accidental or malicious execution of untrusted JavaScript on the server, and is strongly recommended for production environments. And prevent leakage of server-side code to the client (Especially in the case of RSC).
131
+
# Default is false for backward compatibility, but enabling this option is a best practice for security.
Copy file name to clipboardExpand all lines: docs/core-concepts/webpack-configuration.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,38 @@ default: &default
78
78
79
79
The `bin/switch-bundler` script automatically updates this configuration when switching bundlers.
80
80
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
+
81
113
Per the example repo [shakacode/react_on_rails_demo_ssr_hmr](https://github.com/shakacode/react_on_rails_demo_ssr_hmr),
82
114
you should consider keeping your codebase mostly consistent with the defaults for [Shakapacker](https://github.com/shakacode/shakapacker).
0 commit comments