diff --git a/app/views/layouts/spotlight/base.html.erb b/app/views/layouts/spotlight/base.html.erb
index 619527cb5c..277f17b0f5 100644
--- a/app/views/layouts/spotlight/base.html.erb
+++ b/app/views/layouts/spotlight/base.html.erb
@@ -13,7 +13,11 @@
<% else %>
<%= stylesheet_link_tag "application" %>
<% end %>
- <%= javascript_include_tag "application" %>
+ <% if defined? Importmap %>
+ <%= javascript_importmap_tags %>
+ <% else %>
+ <%= javascript_include_tag "application" %>
+ <% end %>
<%= csrf_meta_tags %>
<%= content_for(:head) %>
<%= description %>
diff --git a/lib/generators/spotlight/install_generator.rb b/lib/generators/spotlight/install_generator.rb
index ed02818cf1..5dd464bd88 100644
--- a/lib/generators/spotlight/install_generator.rb
+++ b/lib/generators/spotlight/install_generator.rb
@@ -19,13 +19,21 @@ def add_js_rails6
end
def add_manifest
- # Blacklight 8 does not use this directory by default.
- return unless File.exist?('app/assets/javascripts')
-
- append_to_file 'app/assets/javascripts/application.js', "\n//= require_tree .\n"
append_to_file 'app/assets/config/manifest.js', "\n//= link spotlight/manifest.js"
- # Rails installed importmap by default, but we don't have importmap + Blacklight 7 working yet.
- remove_file 'app/javascript/application.js'
+
+ # Blacklight 8 does not use this directory by default.
+ if File.exist?('app/assets/javascripts')
+ append_to_file 'app/assets/javascripts/application.js', "\n//= require_tree .\n"
+ # Rails installed importmap by default, but we don't have importmap + Blacklight 7 working yet.
+ remove_file 'app/javascript/application.js'
+ else
+ # install via importmap
+ append_to_file 'app/javascript/application.js' do
+ <<~CONTENT
+ import Spotlight from "spotlight.esm"
+ CONTENT
+ end
+ end
end
def inject_spotlight_routes