Skip to content

Commit

Permalink
Expose the original, uncompiled assets in importmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 15, 2022
1 parent 3cf94b2 commit b682c57
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/importmap.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

pin_all_from File.expand_path("../app/javascript/blacklight", __dir__)
pin_all_from File.expand_path("../app/javascript", __dir__)
6 changes: 5 additions & 1 deletion lib/blacklight/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ class Engine < Rails::Engine
end

initializer "blacklight.importmap", before: "importmap" do |app|
app.config.importmap.paths << Engine.root.join("config/importmap.rb") if app.config.respond_to?(:importmap)
if app.config.respond_to?(:importmap)
app.config.assets.precompile += Dir.glob(Engine.root.join("app/javascript/**/*.js"))
app.config.assets.paths << Engine.root.join('app', 'javascript')
app.config.importmap.paths << Engine.root.join("config/importmap.rb")
end
end

bl_global_config = OpenStructWithHashAccess.new
Expand Down
3 changes: 1 addition & 2 deletions lib/generators/blacklight/assets/importmap_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def import_javascript_assets
<<~CONTENT
pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/core@2.11.6/dist/umd/popper.min.js"
pin "bootstrap", to: "https://ga.jspm.io/npm:bootstrap@#{(defined?(Bootstrap) && Bootstrap::VERSION) || '5.2.2'}/dist/js/bootstrap.js"
pin "blacklight", to: "blacklight/blacklight.js"
pin "dialog-polyfill", to: "https://ga.jspm.io/npm:dialog-polyfill@0.5.6/dist/dialog-polyfill.js"
CONTENT
end
Expand All @@ -27,7 +26,7 @@ def append_blacklight_javascript
<<~CONTENT
import bootstrap from "bootstrap"
window.bootstrap = bootstrap // Required for Blacklight 7 so it can manage the modals
import "blacklight"
import Blacklight from "blacklight"
import dialogPolyfill from "dialog-polyfill"
Blacklight.onLoad(() => {
const dialog = document.querySelector('dialog')
Expand Down

0 comments on commit b682c57

Please sign in to comment.