Skip to content

Commit

Permalink
fix(js): allow pinning importmaps with gem
Browse files Browse the repository at this point in the history
Since importmaps and JSPM and the javascript eco system is a mess in its current state, allow importmaps to match the assets served by the gem rather than download them from JSPM.
  • Loading branch information
mhenrixon committed Feb 12, 2024
1 parent 1e68377 commit 9dfff06
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/turbo_boost/streams/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@
require_relative "patches"

class TurboBoost::Engine < ::Rails::Engine
config.turbo_boost_streams = ActiveSupport::OrderedOptions.new
config.turbo_boost_streams.precompile_assets = true

config.after_initialize do
::Turbo::Streams::TagBuilder.send :include, TurboBoost::Streams::Patches::TagBuilder
::Turbo::Streams::Broadcasts.send :include, TurboBoost::Streams::Patches::Broadcasts
::Turbo::Broadcastable.send :include, TurboBoost::Streams::Patches::Broadcastable
end

initializer "turbo_boost_streams.asset" do
config.after_initialize do |app|
if app.config.respond_to?(:assets) && app.config.turbo_boost_streams.precompile_assets
app.config.assets.precompile += %w[turbo_boost/streams.js]
end
end
end
end

0 comments on commit 9dfff06

Please sign in to comment.