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
Copy file name to clipboardexpand all lines: CHANGELOG.md
+2
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,8 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
14
14
## Versions
15
15
### [Unreleased]
16
16
Changes since the last non-beta release.
17
+
#### Added
18
+
- Pack Generation: Added functionality that will add an import statement, if missing, to the server bundle entrypoint even if the autobundle generated files still exist [PR 1610](https://github.com/shakacode/react_on_rails/pull/1610) by [judahmeek](https://github.com/judahmeek).
17
19
18
20
### [14.0.0] - 2024-04-03
19
21
_Major bump because dropping support for Ruby 2.7 and deprecated `webpackConfigLoader.js`._
Copy file name to clipboardexpand all lines: docs/guides/file-system-based-automated-bundle-generation.md
+16-5
Original file line number
Diff line number
Diff line change
@@ -36,15 +36,26 @@ You can change the value in `config/initializers/react_on_rails` by updating it
36
36
config.auto_load_bundle = true
37
37
```
38
38
39
+
### Location of generated files
40
+
Generated files will go to the following two directories:
41
+
* Pack files for entrypoint components will be generated in the `{Shakapacker.config.source_entry_path}/generated` directory.
42
+
* The interim server bundle file, which is only generated if you already have a server bundle entrypoint and have not set `make_generated_server_bundle_the_entrypoint` to `true`, will be generated in the `{Pathname(Shakapacker.config.source_entry_path).parent}/generated` directory.
43
+
39
44
### Update `.gitignore` file
40
-
React on Rails automatically generates pack files for components to be registered in the `packs/generated` directory. To avoid committing generated files into the version control system, please update `.gitignore` to have
45
+
To avoid committing generated files to your version control system, please update `.gitignore` to include:
41
46
42
47
```gitignore
43
48
# Generated React on Rails packs
44
-
app/javascript/packs/generated
49
+
**/generated/**
45
50
```
46
51
47
-
*Note: the directory might be different depending on the `source_entry_path` in `config/shakapacker.yml`.*
52
+
### Commit changes to server bundle entrypoint
53
+
If you already have an existing server bundle entrypoint and have not set `make_generated_server_bundle_the_entrypoint` to `true`, then pack generation will add an import statement to your existing server bundle entrypoint similar to:
54
+
```javascript
55
+
// import statement added by react_on_rails:generate_packs rake task
We recommend committing this import statement to your version control system.
48
59
49
60
## Usage
50
61
@@ -126,7 +137,7 @@ The tricky part is to figure out which bundles to load on any Rails view. [Shaka
126
137
127
138
File-system-based automated pack generation simplifies this process with a new option for the view helpers.
128
139
129
-
For example, if you wanted to utilize our file-system based entrypoint generation for `FooComponentOne`&`BarComponentOne`, but not `BarComponentTwo` (for whatever reason), then...
140
+
For example, if you wanted to utilize our file-system based entrypoint generation for `FooComponentOne`and`BarComponentOne`, but not `BarComponentTwo` (for whatever reason), then...
130
141
131
142
1. Remove generated entrypoints from parameters passed directly to `javascript_pack_tag` and `stylesheet_pack_tag`.
132
143
2. Remove generated entrypoints from parameters passed directly to `append_javascript_pack_tag` and `append_stylesheet_pack_tag`.
@@ -186,7 +197,7 @@ For example, if you wanted to utilize our file-system based entrypoint generatio
186
197
187
198
If server rendering is enabled, the component will be registered for usage both in server and client rendering. In order to have separate definitions for client and server rendering, name the component files as `ComponentName.server.jsx` and `ComponentName.client.jsx`. The `ComponentName.server.jsx` file will be used for server rendering and the `ComponentName.client.jsx` file for client rendering. If you don't want the component rendered on the server, you should only have the `ComponentName.client.jsx` file.
188
199
189
-
Once generated, all server entrypoints will be imported into a file named `[ReactOnRails.configuration.server_bundle_js_file]-generated.js`, which in turn will be imported into a source file named the same as `ReactOnRails.configuration.server_bundle_js_file`. If your server bundling logic is such that your server bundle source entrypoint is not named the same as your `ReactOnRails.configuration.server_bundle_js_file` & changing it would be difficult, please let us know.
200
+
Once generated, all server entrypoints will be imported into a file named `[ReactOnRails.configuration.server_bundle_js_file]-generated.js`, which in turn will be imported into a source file named the same as `ReactOnRails.configuration.server_bundle_js_file`. If your server bundling logic is such that your server bundle source entrypoint is not named the same as your `ReactOnRails.configuration.server_bundle_js_file` and changing it would be difficult, please let us know.
190
201
191
202
*Note: If specifying separate definitions for client and server rendering, please make sure to delete the generalized `ComponentName.jsx` file.*
0 commit comments