Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/custom_elements/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ module CustomElements
module Rails
class Railtie < ::Rails::Engine
initializer "custom_elements-rails.assets.precompile" do |app|
if app.config.respond_to? :assets
if app.config.respond_to?(:assets)
app.config.assets.precompile += %w( custom_elements-rails.js )
end
end

initializer "custom_elements-rails.configure_spark", after: "hotwire_spark.config" do |app|
spark_available = app.config.respond_to?(:hotwire) && app.config.hotwire.respond_to?(:spark)
if spark_available
# Custom elements don't seem to work with morphing
Hotwire::Spark.html_reload_method = :replace

# Just force full reloads after custom element change for now
Hotwire::Spark.html_paths << ::Rails.root.join("app/javascript/custom_elements").to_s
Hotwire::Spark.html_extensions << "js"
end
end
end
end
end
Loading