Skip to content

Commit

Permalink
Add cache sweeping for importmap
Browse files Browse the repository at this point in the history
Lots of this is taken from solidusio/solidus@64de7bd
  • Loading branch information
tvdeyen committed Jun 28, 2023
1 parent b163ae2 commit 352762a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/alchemy/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ class Engine < Rails::Engine

initializer "alchemy.importmap" do |app|
Alchemy.importmap.draw(Engine.root.join("config", "importmap.rb"))
app.config.assets.paths << Alchemy::Engine.root.join("package")

package_path = Engine.root.join("package")
app.config.assets.paths << package_path

if app.config.importmap.sweep_cache
Alchemy.importmap.cache_sweeper(watches: package_path)
ActiveSupport.on_load(:action_controller_base) do
before_action { Alchemy.importmap.cache_sweeper.execute_if_updated }
end
end
end

# Gutentag downcases all tags before save
Expand Down

0 comments on commit 352762a

Please sign in to comment.