Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Allow users to extend spree admin importmap in their own applications (#12526)

Damian Kaczmarczyk847672e163a0
diff --git a/admin/lib/spree/admin/engine.rb b/admin/lib/spree/admin/engine.rb
index 1877e09430..84671b58cb 100644
--- a/admin/lib/spree/admin/engine.rb
+++ b/admin/lib/spree/admin/engine.rb
@@ -29,12 +29,17 @@ module Spree
initializer 'spree.admin.importmap', after: 'importmap' do |app|
app.config.spree_admin = ActiveSupport::OrderedOptions.new
+ app.config.spree_admin.cache_sweepers = []
app.config.spree_admin.importmap = Importmap::Map.new
app.config.spree_admin.importmap.draw(root.join('config/importmap.rb'))
+ end
+ initializer 'spree.admin.importmap.cache_sweeper', after: 'spree.admin.importmap' do |app|
if app.config.importmap.sweep_cache && app.config.reloading_enabled?
- app.config.spree_admin.importmap.cache_sweeper(watches: root.join("app/javascript"))
+ app.config.spree_admin.cache_sweepers << root.join('app/javascript')
+
+ app.config.spree_admin.importmap.cache_sweeper(watches: app.config.spree_admin.cache_sweepers)
ActiveSupport.on_load(:action_controller_base) do
before_action { app.config.spree_admin.importmap.cache_sweeper.execute_if_updated }