File tree 1 file changed +14
-1
lines changed
lib/custom_elements/rails
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,23 @@ module CustomElements
2
2
module Rails
3
3
class Railtie < ::Rails ::Engine
4
4
initializer "custom_elements-rails.assets.precompile" do |app |
5
- if app . config . respond_to? :assets
5
+ if app . config . respond_to? ( :assets )
6
6
app . config . assets . precompile += %w( custom_elements-rails.js )
7
7
end
8
8
end
9
+
10
+ initializer "custom_elements-rails.spark" , after : "hotwire_spark.config" do |app |
11
+ spark_available = app . config . respond_to? ( :hotwire ) && app . config . hotwire . respond_to? ( :spark )
12
+ if spark_available
13
+ puts "spark_available"
14
+ # Custom elements don't seem to work with morphing
15
+ Hotwire ::Spark . html_reload_method = :replace
16
+
17
+ # Just force full reloads after custom element change for now
18
+ Hotwire ::Spark . html_paths << ::Rails . root . join ( "app/javascript/custom_elements" ) . to_s
19
+ Hotwire ::Spark . html_extensions << "js"
20
+ end
21
+ end
9
22
end
10
23
end
11
24
end
You can’t perform that action at this time.
0 commit comments