hotwire-livereload 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -1
- data/lib/hotwire/livereload/engine.rb +6 -4
- data/lib/hotwire/livereload/version.rb +1 -1
- data/lib/hotwire/livereload.rb +1 -0
- data/lib/tasks/livereload_tasks.rake +21 -0
- metadata +3 -3
- data/lib/tasks/hotwire/livereload/install.rake +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05ad19b6e77492fec265a2da6af3ddd9aa8b7b149ae284397644db40b553974b
|
4
|
+
data.tar.gz: 7f497acf2a34e1774d80c7a2fa1030b6a2eb9228cc2fe257b73a7cdad0e912fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 554901b08d7d257da5660c5020cbfb8bab03e987eff1d329337fa9943119c6e3a8bead3bc62c97edec32250f7c0bb5503b7d306373e794bd7908a208f211284a
|
7
|
+
data.tar.gz: 8e213677c64df89f7903d672c421b7faa9d8a5d12e136ef24e92e7dbc1a0deedc650d92cd882b06627f20e89ddcd4d46ea72943e22cf035152b9aff2e3284c02
|
data/README.md
CHANGED
@@ -10,7 +10,34 @@ The JavaScript for Hotwire::Livereload is installed via asset pipeline, which is
|
|
10
10
|
|
11
11
|
1. Add `hotwire-livereload` gem to your Gemfile: `gem 'hotwire-livereload'`
|
12
12
|
2. Run `./bin/bundle install`
|
13
|
-
3. Run `./bin/rails
|
13
|
+
3. Run `./bin/rails livereload:install`
|
14
|
+
|
15
|
+
## Configuration
|
16
|
+
|
17
|
+
You can watch for changes in additional folders by adding them to `listen_paths`. For example, you can watch for CSS changes:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# config/environments/development.rb
|
21
|
+
|
22
|
+
Rails.application.configure do
|
23
|
+
# ...
|
24
|
+
config.hotwire_livereload.listen_paths << Rails.root.join("app/assets/stylesheets")
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
## Disable livereload
|
29
|
+
|
30
|
+
To temporarily disable livereload use:
|
31
|
+
```bash
|
32
|
+
bin/rails livereload:disable
|
33
|
+
```
|
34
|
+
|
35
|
+
To re-enable:
|
36
|
+
```bash
|
37
|
+
bin/rails livereload:enable
|
38
|
+
```
|
39
|
+
|
40
|
+
No server restart is required. Disabling is managed by `tmp/livereload-disabled.txt` file.
|
14
41
|
|
15
42
|
## Development
|
16
43
|
|
@@ -36,11 +36,13 @@ module Hotwire
|
|
36
36
|
end
|
37
37
|
|
38
38
|
config.after_initialize do |app|
|
39
|
-
if Rails.env.development?
|
39
|
+
if Rails.env.development? && defined?(Rails::Server)
|
40
40
|
@listener = Listen.to(*app.config.hotwire_livereload.listen_paths) do |modified, added, removed|
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
unless File.exists?(DISABLE_FILE)
|
42
|
+
if (modified.any? || removed.any? || added.any?)
|
43
|
+
content = { modified: modified, removed: removed, added: added }
|
44
|
+
ActionCable.server.broadcast("hotwire-reload", content)
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
46
48
|
@listener.start
|
data/lib/hotwire/livereload.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :livereload do
|
2
|
+
desc "Install Hotwire::Livereload into the app"
|
3
|
+
task :install do
|
4
|
+
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/install.rb", __dir__)}"
|
5
|
+
end
|
6
|
+
|
7
|
+
desc "Disable Hotwire::Livereload"
|
8
|
+
task :disable do
|
9
|
+
FileUtils.mkdir_p("tmp")
|
10
|
+
FileUtils.touch Hotwire::Livereload::DISABLE_FILE
|
11
|
+
puts "Livereload disabled."
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Enable Hotwire::Livereload"
|
15
|
+
task :enable do
|
16
|
+
if File.exist?(Hotwire::Livereload::DISABLE_FILE)
|
17
|
+
File.delete Hotwire::Livereload::DISABLE_FILE
|
18
|
+
end
|
19
|
+
puts "Livereload enabled."
|
20
|
+
end
|
21
|
+
end
|
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: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Platonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -55,7 +55,7 @@ files:
|
|
55
55
|
- lib/hotwire/livereload/engine.rb
|
56
56
|
- lib/hotwire/livereload/version.rb
|
57
57
|
- lib/install/install.rb
|
58
|
-
- lib/tasks/
|
58
|
+
- lib/tasks/livereload_tasks.rake
|
59
59
|
homepage: https://github.com/kirillplatonov/hotwire-livereload
|
60
60
|
licenses:
|
61
61
|
- MIT
|