Skip to content

Commit 5b01848

Browse files
authored
Document how to add files to sweep_cache (#50)
1 parent cc2803a commit 5b01848

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,18 @@ end
200200

201201
## Sweeping the cache in development and test
202202

203-
Generating the import map json and modulepreloads may require resolving hundreds of assets. This can take a while, so these operations are cached, but in development and test, we watch for changes to both `config/importmap.rb` and files in `app/javascript` to clear this cache. This feature can be controlled in an environment configuration file via the boolean `config.importmap.sweep_cache`. If you're pinning local files from outside of `app/javascript`, you'll need to restart your development server upon changes to those external files.
203+
Generating the import map json and modulepreloads may require resolving hundreds of assets. This can take a while, so these operations are cached, but in development and test, we watch for changes to both `config/importmap.rb` and files in `app/javascript` to clear this cache. This feature can be controlled in an environment configuration file via the boolean `config.importmap.sweep_cache`.
204204

205+
If you're pinning local files from outside of `app/javascript`, you'll need to add them to the cache sweeper configuration or restart your development server upon changes to those external files. To add them to the configuration to clear the cache on changes, for instance when locally developing an engine, use an initializer like the following sample `config/initializers/importmap-caching.rb`:
206+
207+
```ruby
208+
if Rails.env.development?
209+
Rails.application.importmap.cache_sweeper watches: [
210+
Rails.application.root.join("app/javascript"),
211+
MyEngine::Engine.root.join("app/assets/javascripts"),
212+
]
213+
end
214+
```
205215

206216
## Expected errors from using the es-module-shim
207217

0 commit comments

Comments
 (0)