@@ -42,7 +42,7 @@ class Engine < Rails::Engine
4242 end
4343 end
4444
45- initializer "alchemy.admin_importmap" , before : "alchemy.importmap" do
45+ initializer "alchemy.admin_importmap" do
4646 Alchemy . config . admin_importmaps . add (
4747 importmap_path : root . join ( "config/importmap.rb" ) ,
4848 source_paths : [
@@ -54,21 +54,23 @@ class Engine < Rails::Engine
5454 end
5555
5656 initializer "alchemy.importmap" do |app |
57- watch_paths = [ ]
58-
59- Alchemy . config . admin_importmaps . each do |admin_import |
60- Alchemy . importmap . draw admin_import . importmap_path
61- watch_paths += admin_import . source_paths . to_a
62- app . config . assets . paths += admin_import . source_paths . to_a
63- if admin_import [ :name ] != "alchemy_admin"
64- Alchemy . config . admin_js_imports . add ( admin_import . name )
57+ app . config . to_prepare do
58+ watch_paths = [ ]
59+
60+ Alchemy . config . admin_importmaps . each do |admin_import |
61+ Alchemy . importmap . draw admin_import . importmap_path
62+ watch_paths += admin_import . source_paths . to_a
63+ app . config . assets . paths += admin_import . source_paths . to_a
64+ if admin_import [ :name ] != "alchemy_admin"
65+ Alchemy . config . admin_js_imports . add ( admin_import . name )
66+ end
6567 end
66- end
6768
68- if app . config . importmap . sweep_cache
69- Alchemy . importmap . cache_sweeper ( watches : watch_paths )
70- ActiveSupport . on_load ( :action_controller_base ) do
71- before_action { Alchemy . importmap . cache_sweeper . execute_if_updated }
69+ if app . config . importmap . sweep_cache
70+ Alchemy . importmap . cache_sweeper ( watches : watch_paths )
71+ ActiveSupport . on_load ( :action_controller_base ) do
72+ before_action { Alchemy . importmap . cache_sweeper . execute_if_updated }
73+ end
7274 end
7375 end
7476 end
0 commit comments