Commit e612f66
Simplify configuration files to improve usability (#2011)
## Summary
After PR #1993 introduced sensible defaults for advanced options like
`generated_component_packs_loading_strategy` (auto-configured based on
Pro license), we can significantly simplify generated configuration
files and documentation to make React on Rails easier to use.
This PR reduces configuration complexity while maintaining full
functionality through smart defaults.
## Key Improvements
### Generator Template Simplification
- **Reduced from 67 to 42 lines** (37% reduction)
- Removed redundant explanations for options with good defaults
- Added clear pointer to docs for advanced configuration
- Kept only essential options in generated files
- Made file-system component registry commented out (optional feature)
### Documentation Restructuring
- Added **"Quick Start" section** showing minimal 2-3 line config
- Reorganized into **"Essential" vs "Advanced"** configuration sections
- Documented which options **auto-configure based on Pro license**
- Added clear defaults and recommendations for each option
- Improved searchability with structured sections
- Added deprecation section for `immediate_hydration`
### Configuration Categories
**Essential Configuration** (in generated files):
- `server_bundle_js_file` - Required for SSR
- `build_test_command` - Used for testing
- `components_subdirectory` - Optional file-based registry
- `auto_load_bundle` - Optional auto-loading
**Advanced Configuration** (docs only, sensible defaults):
- `generated_component_packs_loading_strategy` - Auto: `:async` for Pro,
`:defer` for non-Pro
- `server_bundle_output_path` - Default: `"ssr-generated"`
- `enforce_private_server_bundles` - Default: `false`
- All rendering pool, debugging, and customization options
### Dummy App Updates
- Updated all dummy app configs with clear comments
- Separated essential from test-specific configuration
- Maintained same functionality with better organization
## Example: Before and After
**Before** (67 lines with lots of inline documentation):
```ruby
ReactOnRails.configure do |config|
# This configures the script to run to build the production assets by webpack...
# [30 lines of comments explaining options]
config.server_bundle_js_file = "server-bundle.js"
config.server_bundle_output_path = "ssr-generated"
config.enforce_private_server_bundles = true
# [More options and explanations]
end
```
**After** (42 lines, clearer structure):
```ruby
ReactOnRails.configure do |config|
# Server Rendering
config.server_bundle_js_file = "server-bundle.js"
# Test Configuration
config.build_test_command = "RAILS_ENV=test bin/shakapacker"
# File System Based Component Registry (Optional)
# config.components_subdirectory = "ror_components"
# config.auto_load_bundle = true
# Advanced Configuration
# See: https://github.com/shakacode/react_on_rails/blob/master/docs/api-reference/configuration.md
end
```
## Benefits
1. **Reduced cognitive load**: New users see only 2-3 required config
options
2. **Clear upgrade path**: Easy progression from simple to advanced
configuration
3. **Decision fatigue reduction**: Fewer choices to make during setup
4. **Better reflects improvements**: Showcases PR #1993's
auto-configuration
5. **Easier onboarding**: Clearer understanding of what needs
customization
## Testing
- ✅ All configuration specs pass
- ✅ RuboCop passes on all modified files
- ✅ Pre-commit hooks pass (Prettier, ESLint, trailing newlines)
- ✅ Dummy apps load successfully with simplified configs
## Files Changed
-
`lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt`
- Simplified generator template
- `docs/api-reference/configuration.md` - Restructured documentation
with Essential/Advanced sections
- `spec/dummy/config/initializers/react_on_rails.rb` - Updated with
better organization
- `react_on_rails_pro/spec/dummy/config/initializers/react_on_rails.rb`
- Updated Pro dummy
-
`react_on_rails_pro/spec/execjs-compatible-dummy/config/initializers/react_on_rails.rb`
- Updated execjs dummy
## Related
- Follow-up to PR #1993 (immediate hydration and loading strategy
auto-configuration)
- Addresses the goal of making React on Rails easier to use with
sensible defaults
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/2011)
<!-- Reviewable:end -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Documentation**
* Added a reworked main configuration reference with examples, a
deprecated/removed options guide, Pro configuration docs, and a new
testing-configuration guide.
* **New Features**
* Added diagnostics that detect inconsistent server-side rendering and
test asset compilation setups and surface actionable guidance.
* **Tests**
* Updated test app configuration examples and defaults to clarify
testing behaviors and recommended setups.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent cbee429 commit e612f66
File tree
10 files changed
+1327
-416
lines changed- docs
- api-reference
- guides
- lib
- generators/react_on_rails/templates/base/base/config/initializers
- react_on_rails
- react_on_rails_pro/spec
- dummy/config/initializers
- execjs-compatible-dummy/config/initializers
- spec/dummy/config/initializers
10 files changed
+1327
-416
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
0 commit comments