react-rails-hot-loader 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -3
- data/lib/hot_loader/asset_change_set.rb +12 -2
- data/lib/hot_loader/version.rb +1 -1
- data/lib/react-rails-hot-loader.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ccd666621d038150005b210e1780351a32c3869
|
4
|
+
data.tar.gz: 3b162749ab5c6fc4dddf9c9afec34f9cb0588b83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b73516078d8c51f6cb23ee7525e29f5e4adfccd35e23f449884a5b5c1d8bc0de3c6fa3e071f6bdbf82872a469a6e63c6b0d75d40032b1476d994e94e48cb735
|
7
|
+
data.tar.gz: 98500e70dfe7c7d137a995cb63ae65ac349a90ccb29d4d34892d49a02b3a201d9a87873e602a4f79fb9797b95df937d23b024d6a7b710ac15971530f34577535
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -27,7 +27,7 @@ Or install it yourself as:
|
|
27
27
|
- Add an initializer:
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
#
|
30
|
+
# config/initializers/react_rails_hot_loader.rb
|
31
31
|
if Rails.env.development?
|
32
32
|
React::Rails::HotLoader.start()
|
33
33
|
end
|
@@ -51,7 +51,7 @@ Or install it yourself as:
|
|
51
51
|
If you notice that your assets are not being recompiled and hot loaded, it could be because they aren't being matched by the default asset glob used (`**/*.{js,coffee}*`). You can modify this asset glob like so:
|
52
52
|
|
53
53
|
```ruby
|
54
|
-
#
|
54
|
+
# config/initializers/react_rails_hot_loader.rb
|
55
55
|
React::Rails::HotLoader::AssetChangeSet.asset_glob = "**/*.{js,rb}*" # I <3 Opal
|
56
56
|
```
|
57
57
|
|
@@ -62,7 +62,6 @@ React::Rails::HotLoader::AssetChangeSet.asset_glob = "**/*.{js,rb}*" # I <3 Opal
|
|
62
62
|
- __does__ set up a WebSocket server & client
|
63
63
|
- __does__ reload JS assets when they change (from `/app/assets/javascripts/*.{js,coffee}*`)
|
64
64
|
- __does__ remount components (via `ReactRailsUJS`) after reloading assets
|
65
|
-
- __does__ preserve state & props (because `React.render` does that out of the box)
|
66
65
|
- __doesn't__ reload Rails view files (`html`, `erb`, `slim`, etc)
|
67
66
|
- __doesn't__ reload CSS (although that could be fixed)
|
68
67
|
|
@@ -15,8 +15,9 @@ module React
|
|
15
15
|
@changed_files = Dir.glob(asset_glob).select { |f| File.mtime(f) >= since }
|
16
16
|
@changed_file_names = changed_files.map { |f| f.split("/").last }
|
17
17
|
@changed_asset_contents = changed_files.map do |f|
|
18
|
-
logical_path = f
|
19
|
-
::Rails.application.assets[logical_path]
|
18
|
+
logical_path = to_logical_path(f)
|
19
|
+
asset = ::Rails.application.assets[logical_path]
|
20
|
+
asset.to_s
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
@@ -32,6 +33,15 @@ module React
|
|
32
33
|
changed_asset_contents: changed_asset_contents,
|
33
34
|
}
|
34
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def to_logical_path(asset_path)
|
40
|
+
asset_path
|
41
|
+
.sub(@path, "") # remove the basepath
|
42
|
+
.sub(/^\//, '') # remove any leading /
|
43
|
+
.sub(/\.js.*/, '.js') # replace any file extension with `.js`
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
37
47
|
end
|
data/lib/hot_loader/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react-rails-hot-loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-websocket
|