Last active
April 3, 2024 21:58
-
-
Save varyform/92be68c3ea2d94d31de3c3359284c0e5 to your computer and use it in GitHub Desktop.
Multiple importmaps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/public_importmap.rb | |
Rails.application.config.public_importmap = Importmap::Map.new | |
Rails.application.config.public_importmap.draw(Rails.root.join("config/public_importmap.rb")) | |
# app/helpers/application_helper.rb | |
# copied from importmaps replacing javascript_inline_importmap_tag | |
# | |
# !!! No longer needed after this change https://github.com/rails/importmap-rails/pull/187 | |
# | |
# def javascript_public_importmap_tags(entry_point = "application", shim: true) | |
# safe_join [ | |
# javascript_inline_importmap_tag(Rails.application.config.public_importmap.to_json(resolver: self)), | |
# javascript_importmap_module_preload_tags(Rails.application.config.public_importmap) | |
# (javascript_importmap_shim_nonce_configuration_tag if shim), | |
# (javascript_importmap_shim_tag if shim), | |
# javascript_import_module_tag(entry_point) | |
# ].compact, "\n" | |
# end | |
# config/public_importmap.rb | |
# whatever you need | |
pin "@hotwired/turbo-rails", to: "turbo.js" | |
pin "public" |
Line 10:
javascript_importmap_module_preload_tags
Unless you want to prefetch everything including those in the default importmap you probably want to use
javascript_importmap_module_preload_tags(Rails.application.config.public_importmap)
Fixed, thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unless you want to prefetch everything including those in the default importmap you probably want to use