Skip to content

Commit 3473b57

Browse files
justin808claude
andcommitted
Improve configuration documentation based on code review feedback
Address code review suggestions to improve clarity and usability of configuration documentation and generated config files. Key improvements: Documentation clarity: - Remove redundant Quick Start code block, reference Essential Configuration instead - Add clarification that build_test_command is used with TestHelper - Add context for File-Based Component Registry explaining use cases - Add stronger warning to server_bundle_output_path with prominent notice - Add use case guidance for when to override auto-configured settings - Add "When to disable" guidance for replay_console option - Add introductory context for I18n configuration section Generated template improvements: - Clarify build_test_command usage with TestHelper in comments - Emphasize that compile: true in shakapacker.yml is preferred alternative Dummy app improvements: - Add prominent warning to all dummy app configs to prevent cargo-culting - Clearly mark as "TEST CONFIGURATION - Do not copy directly for production" All changes maintain backward compatibility and improve the developer experience by providing clearer guidance on which options need configuration and when to override defaults. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 5b07560 commit 3473b57

File tree

5 files changed

+27
-25
lines changed

5 files changed

+27
-25
lines changed

docs/api-reference/configuration.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,7 @@ This document describes all configuration options for React on Rails. Configurat
66
77
## Quick Start
88

9-
For most applications, your configuration file can be as simple as:
10-
11-
```ruby
12-
ReactOnRails.configure do |config|
13-
config.server_bundle_js_file = "server-bundle.js"
14-
config.build_test_command = "RAILS_ENV=test bin/shakapacker"
15-
end
16-
```
17-
18-
See [Essential Configuration](#essential-configuration) below for the options you'll commonly use.
9+
See [Essential Configuration](#essential-configuration) below for the minimal configuration options you'll commonly use. Most applications only need 1-2 settings!
1910

2011
## Prerequisites
2112

@@ -65,7 +56,7 @@ React on Rails configuration options are organized into two categories:
6556
Options you'll commonly configure for most applications:
6657
6758
- `server_bundle_js_file` - Server rendering bundle (recommended)
68-
- `build_test_command` - Test environment build command (alternative to Shakapacker compile setting)
59+
- `build_test_command` - Test environment build command (used with `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`)
6960

7061
### Advanced Configuration
7162

@@ -141,7 +132,9 @@ test:
141132
142133
## File-Based Component Registry
143134
144-
For information about the file-based component registry feature (including `components_subdirectory`, `auto_load_bundle`, and `make_generated_server_bundle_the_entrypoint` configuration options), see:
135+
If you have many components and want to avoid manually managing webpack entry points for each one, React on Rails can automatically generate component packs based on your file system structure. This feature is particularly useful for large applications with dozens of components.
136+
137+
For complete information about the file-based component registry feature (including `components_subdirectory`, `auto_load_bundle`, and `make_generated_server_bundle_the_entrypoint` configuration options), see:
145138

146139
[Auto-Bundling: File-System-Based Automated Bundle Generation](../core-concepts/auto-bundling-file-system-based-automated-bundle-generation.md)
147140

@@ -165,7 +158,7 @@ Controls how generated component pack scripts are loaded:
165158

166159
**You typically don't need to set this** - React on Rails automatically selects the best strategy based on your Pro license status and Shakapacker version.
167160

168-
To override the default:
161+
**When to override:** Only change this if you have specific performance requirements or constraints. For example, you might use `:defer` if you need to ensure all page content loads before scripts execute, or `:sync` for testing purposes.
169162

170163
```ruby
171164
config.generated_component_packs_loading_strategy = :defer
@@ -178,10 +171,13 @@ config.generated_component_packs_loading_strategy = :defer
178171
**Type:** String or nil
179172
**Default:** `"ssr-generated"`
180173

181-
Directory (relative to Rails root) where server bundles are output. **You should not need to set this** - the default value is recommended for all applications.
174+
> ⚠️ **DO NOT change this setting unless you have a specific reason.** The default is correct for virtually all applications.
175+
176+
Directory (relative to Rails root) where server bundles are output.
182177

183178
```ruby
184-
config.server_bundle_output_path = "ssr-generated" # default (no need to set)
179+
# No need to set this - the default is recommended
180+
# config.server_bundle_output_path = "ssr-generated"
185181
```
186182

187183
- When set to a string: Server bundles output to this directory (e.g., `ssr-generated/`)
@@ -325,12 +321,14 @@ config.development_mode = Rails.env.development? # default
325321
**Type:** Boolean
326322
**Default:** `true`
327323

328-
When true, server-side console messages replay in the browser console:
324+
When true, server-side console messages replay in the browser console. This is valuable for debugging server-rendering issues.
329325

330326
```ruby
331327
config.replay_console = true # default
332328
```
333329

330+
**When to disable:** You might set this to `false` in production if console logs contain sensitive data or to reduce client-side payload size.
331+
334332
#### logging_on_server
335333

336334
**Type:** Boolean
@@ -427,6 +425,8 @@ Set to `0` to wait indefinitely (not recommended for production).
427425

428426
### I18n Configuration
429427

428+
These options are for applications using [react-intl](https://formatjs.io/docs/react-intl/) or similar internationalization libraries. If your application doesn't need i18n, you can skip this section.
429+
430430
#### i18n_dir
431431

432432
**Type:** String or nil

lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ ReactOnRails.configure do |config|
1414

1515
################################################################################
1616
# Test Configuration
17-
# Alternatively, set `compile: true` in config/shakapacker.yml for test env
17+
# Used with ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
18+
# Preferred alternative: set `compile: true` in config/shakapacker.yml for test env
1819
################################################################################
1920
config.build_test_command = "RAILS_ENV=test bin/shakapacker"
2021

react_on_rails_pro/spec/dummy/config/initializers/react_on_rails.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# frozen_string_literal: true
22

3-
# Pro dummy app configuration for testing React on Rails Pro features
4-
# See docs/api-reference/configuration.md for complete documentation
3+
# ⚠️ TEST CONFIGURATION - Do not copy directly for production apps
4+
# This is the Pro dummy app configuration used for testing React on Rails Pro features.
5+
# See docs/api-reference/configuration.md for production configuration guidance.
56

67
# Advanced: Custom rendering extension to add values to railsContext
78
module RenderingExtension

react_on_rails_pro/spec/execjs-compatible-dummy/config/initializers/react_on_rails.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
22

3-
# ExecJS-compatible dummy app configuration
4-
# This app tests compatibility with legacy webpacker setup
5-
# See docs/api-reference/configuration.md for complete documentation
3+
# ⚠️ TEST CONFIGURATION - Do not copy directly for production apps
4+
# This is the ExecJS-compatible dummy app for testing legacy webpacker compatibility.
5+
# See docs/api-reference/configuration.md for production configuration guidance.
66

77
ReactOnRails.configure do |config|
88
################################################################################

spec/dummy/config/initializers/react_on_rails.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
22

3-
# Dummy app configuration for testing React on Rails
4-
# This demonstrates both essential and advanced configuration options for testing purposes
5-
# See docs/api-reference/configuration.md for complete documentation
3+
# ⚠️ TEST CONFIGURATION - Do not copy directly for production apps
4+
# This is the dummy app configuration used for testing React on Rails features.
5+
# See docs/api-reference/configuration.md for production configuration guidance.
66

77
# Advanced: Custom rendering extension to add values to railsContext
88
module RenderingExtension

0 commit comments

Comments
 (0)