hotwire-livereload 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -0
- data/app/assets/javascripts/hotwire-livereload-turbo-stream.js +1 -0
- data/app/assets/javascripts/hotwire-livereload.js +1 -0
- data/app/javascript/lib/hotwire-livereload-received.js +1 -0
- data/lib/hotwire/livereload/engine.rb +2 -1
- data/lib/hotwire/livereload/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44376128ac37b1619d34c7ee8dee64eb1901804cc170dd0bd5c2114973e98225
|
4
|
+
data.tar.gz: 9053700099d671c33b11fa0483100ec5f921016a7e2f1315113072c5c1bba587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5677a61e971bfa24bb8c8ea76970420e370e03003f07970632bf07b22c187cc6dfc3289963509c8597f7b12c08e112d8db56f308fa85008023c3160a9f700846
|
7
|
+
data.tar.gz: 4e91a4a01f3e5b8d54e18b2344351c17bef3e1ac09568adc3b1802dc6a8f95eaa4abc6c972e93c8edd7eafa61a944e2b390e339697b1bc802cc7a8e85176b6ff
|
data/README.md
CHANGED
@@ -34,6 +34,8 @@ The gem detects if you use [`jsbundling-rails`](https://github.com/rails/jsbundl
|
|
34
34
|
|
35
35
|
## Configuration
|
36
36
|
|
37
|
+
### Listen paths
|
38
|
+
|
37
39
|
You can watch for changes in additional folders by adding them to `listen_paths`:
|
38
40
|
```ruby
|
39
41
|
# config/environments/development.rb
|
@@ -58,6 +60,8 @@ Rails.application.configure do
|
|
58
60
|
end
|
59
61
|
```
|
60
62
|
|
63
|
+
### Force reload
|
64
|
+
|
61
65
|
If you don't have `data-turbo-track="reload"` attribute on your JS and CSS bundles you might need to setup force reloading. This will trigger full browser reloading for JS and CSS files only:
|
62
66
|
```ruby
|
63
67
|
# config/environments/development.rb
|
@@ -69,6 +73,8 @@ Rails.application.configure do
|
|
69
73
|
end
|
70
74
|
```
|
71
75
|
|
76
|
+
### Reload method
|
77
|
+
|
72
78
|
Instead of a direct ActionCable websocket connection, you can reuse the existing TurboStream websocket connection and send updates using standard turbo-streams:
|
73
79
|
```ruby
|
74
80
|
# config/environments/development.rb
|
@@ -90,6 +96,22 @@ In that case you need to place `hotwire_livereload_tags` helper in your layout *
|
|
90
96
|
</head>
|
91
97
|
```
|
92
98
|
|
99
|
+
### Listen options
|
100
|
+
|
101
|
+
[Listen gem](https://github.com/guard/listen), which is used for file system monitoring, accepts [options](https://github.com/guard/listen?tab=readme-ov-file#options) like enabling a fallback mechanism called "polling" to detect file changes.
|
102
|
+
|
103
|
+
By default, Listen uses a more efficient mechanism called "native" which relies on the operating system's file system events to detect changes. However, in some cases, such as when working with network-mounted file systems or in certain virtualized environments, the native mechanism may not work reliably. In such cases, enabling force_polling ensures that file changes are still detected, albeit with a slightly higher resource usage.
|
104
|
+
|
105
|
+
You may use listen_options to pass these options like:
|
106
|
+
```ruby
|
107
|
+
# config/environments/development.rb
|
108
|
+
|
109
|
+
Rails.application.configure do
|
110
|
+
# ...
|
111
|
+
config.hotwire_livereload.listen_options[:force_polling] = true
|
112
|
+
end
|
113
|
+
```
|
114
|
+
|
93
115
|
## Disable livereload
|
94
116
|
|
95
117
|
To temporarily disable livereload use:
|
@@ -15,6 +15,7 @@ module Hotwire
|
|
15
15
|
#{root}/app/channels
|
16
16
|
#{root}/app/helpers
|
17
17
|
]
|
18
|
+
config.hotwire_livereload.listen_options ||= {}
|
18
19
|
|
19
20
|
initializer "hotwire_livereload.assets" do
|
20
21
|
if Rails.application.config.respond_to?(:assets)
|
@@ -63,7 +64,7 @@ module Hotwire
|
|
63
64
|
listen_paths = options.listen_paths.map(&:to_s).uniq
|
64
65
|
force_reload_paths = options.force_reload_paths.map(&:to_s).uniq.join("|")
|
65
66
|
|
66
|
-
@listener = Listen.to(*listen_paths) do |modified, added, removed|
|
67
|
+
@listener = Listen.to(*listen_paths, **config.hotwire_livereload.listen_options) do |modified, added, removed|
|
67
68
|
unless File.exist?(DISABLE_FILE)
|
68
69
|
changed = [modified, removed, added].flatten.uniq
|
69
70
|
next unless changed.any?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotwire-livereload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Platonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|