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
For more details on Rspack configuration, see the [Webpack Configuration](../core-concepts/webpack-configuration.md#rspack-vs-webpack) docs.
173
+
109
174
### Auto-Bundling and Component Registration
110
175
111
176
Modern React on Rails uses auto-bundling to eliminate manual webpack configuration. Components placed in the configured `components_subdirectory` (default: `ror_components`) are automatically:
Copy file name to clipboardExpand all lines: docs/core-concepts/webpack-configuration.md
+67Lines changed: 67 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,73 @@
11
11
12
12
To get a deeper understanding of Shakapacker, watch [RailsConf 2020 CE - Webpacker, It-Just-Works, But How? by Justin Gordon](https://youtu.be/sJLoOpc5LD8).
13
13
14
+
## Rspack vs. Webpack
15
+
16
+
[Rspack](https://rspack.dev/) is a high-performance JavaScript bundler written in Rust that provides significantly faster builds than Webpack (~20x improvement). React on Rails supports both bundlers through unified configuration.
17
+
18
+
### Using Rspack
19
+
20
+
Generate a new app with Rspack:
21
+
22
+
```bash
23
+
rails generate react_on_rails:install --rspack
24
+
```
25
+
26
+
Or switch an existing app to Rspack:
27
+
28
+
```bash
29
+
bin/switch-bundler rspack
30
+
```
31
+
32
+
### Performance Benefits
33
+
34
+
-**Build times**: ~53-270ms with Rspack vs typical webpack builds
35
+
-**~20x faster transpilation** with SWC (used by Rspack)
36
+
-**Faster development** builds and CI runs
37
+
38
+
### Unified Configuration
39
+
40
+
React on Rails generates unified webpack configuration files that work with both bundlers:
Rspack configuration is controlled via `config/shakapacker.yml`:
72
+
73
+
```yaml
74
+
default: &default
75
+
assets_bundler: 'rspack'# or 'webpack'
76
+
webpack_loader: 'swc'# Rspack works best with SWC
77
+
```
78
+
79
+
The `bin/switch-bundler` script automatically updates this configuration when switching bundlers.
80
+
14
81
Per the example repo [shakacode/react_on_rails_demo_ssr_hmr](https://github.com/shakacode/react_on_rails_demo_ssr_hmr),
15
82
you should consider keeping your codebase mostly consistent with the defaults for [Shakapacker](https://github.com/shakacode/shakapacker).
Take a look at the files created by the generator.
@@ -41,6 +44,8 @@ Take a look at the files created by the generator.
41
44
- A sample controller and view
42
45
- Webpack configuration
43
46
47
+
> 💡 **Performance Tip:** Add the `--rspack` flag for significantly faster builds (~20x improvement). You can also switch bundlers later with `bin/switch-bundler rspack`.
48
+
44
49
## 🎯 Step 2: Start the Development Server (1 minute)
45
50
46
51
> **Note:** Ensure you have `overmind` or `foreman` installed to run `bin/dev`.
0 commit comments