diff --git a/lib/turbo_boost/streams/engine.rb b/lib/turbo_boost/streams/engine.rb index 92191ec..091e2b6 100644 --- a/lib/turbo_boost/streams/engine.rb +++ b/lib/turbo_boost/streams/engine.rb @@ -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