webpack-rails-helper 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/webpack-rails-helper.rb +0 -5
- data/lib/webpack/rails_helper/config.rb +19 -12
- data/lib/webpack/rails_helper/manifest.rb +4 -1
- data/lib/webpack/rails_helper/railtie.rb +4 -2
- data/lib/webpack/rails_helper/version.rb +1 -1
- 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: eff1373c5bf4eb7d1ced1c3620173475f4e69c72
|
|
4
|
+
data.tar.gz: 8f828bea26707149d73f8d1bdea2e6645d49bb36
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8c177ff15970dcd064cd3904fbcda73abc786e86e070a2c540b6912a4c56e57db4c19f629ccfda57b0af2c3d783050c4bebf86479e11cadfe99030319ec70b4e
|
|
7
|
+
data.tar.gz: b2790c13bf57cdec749dee068b056a501e94bee3a9b9ee6acdaac04a128ffab8ce8b82a3a4fd6e5b875ceaf8b27514ea6bfc449362eb2b0652d58370fbd4621b
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# webpack-rails-helper
|
|
2
2
|
|
|
3
|
-
This gem integrates assets from webpack into a Ruby on Rails application.
|
|
3
|
+
This gem integrates assets from webpack into a Ruby on Rails application. It
|
|
4
4
|
basically converts between the asset name and the asset name as emitted by
|
|
5
5
|
webpack with hashes and stuff added.
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ webpack with hashes and stuff added.
|
|
|
8
8
|
This works by using a JSON manifest file. When using together with
|
|
9
9
|
`webpack-dev-server`, the manifest is re-read on every call to one of the
|
|
10
10
|
helpers. This isn't exactly efficient but isn't much of a problem in development
|
|
11
|
-
mode. In production mode, the manifest is read once.
|
|
11
|
+
mode. In production mode, the manifest is read once from file.
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
@@ -104,7 +104,7 @@ The gem provides helper methods, available in views and controllers:
|
|
|
104
104
|
automatically if required.
|
|
105
105
|
|
|
106
106
|
|
|
107
|
-
*
|
|
107
|
+
* Stylesheet tag:
|
|
108
108
|
|
|
109
109
|
```
|
|
110
110
|
stylesheet_webpack_tag(*names, **options)
|
data/lib/webpack-rails-helper.rb
CHANGED
|
@@ -7,18 +7,11 @@ class Webpack::RailsHelper::Config
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def asset_prefix
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
host = config_root.dev_server.host
|
|
16
|
-
host = instance_eval(&host) if host.respond_to?(:call)
|
|
17
|
-
|
|
18
|
-
"#{protocol}://#{host}:#{port}"
|
|
19
|
-
else
|
|
20
|
-
''
|
|
21
|
-
end + "/#{config_root.public_path}/"
|
|
10
|
+
if config_root.dev_server.enabled
|
|
11
|
+
dev_server_asset_prefix
|
|
12
|
+
else
|
|
13
|
+
static_asset_prefix
|
|
14
|
+
end
|
|
22
15
|
end
|
|
23
16
|
|
|
24
17
|
def static_manifest_path
|
|
@@ -36,6 +29,20 @@ class Webpack::RailsHelper::Config
|
|
|
36
29
|
|
|
37
30
|
private
|
|
38
31
|
|
|
32
|
+
def static_asset_prefix
|
|
33
|
+
@asset_prefix ||= "/#{config_root.public_path}/"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def dev_server_asset_prefix
|
|
37
|
+
port = config_root.dev_server.port
|
|
38
|
+
protocol = config_root.dev_server.https ? 'https' : 'http'
|
|
39
|
+
|
|
40
|
+
host = config_root.dev_server.host
|
|
41
|
+
host = instance_eval(&host) if host.respond_to?(:call)
|
|
42
|
+
|
|
43
|
+
"#{protocol}://#{host}:#{port}/#{config_root.public_path}/"
|
|
44
|
+
end
|
|
45
|
+
|
|
39
46
|
def config_root
|
|
40
47
|
::Rails.configuration.webpack
|
|
41
48
|
end
|
|
@@ -21,6 +21,10 @@ module Webpack
|
|
|
21
21
|
nil
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def clear_manifest
|
|
25
|
+
@manifest = nil
|
|
26
|
+
end
|
|
27
|
+
|
|
24
28
|
private
|
|
25
29
|
|
|
26
30
|
def single_asset_path(manif, source, optional)
|
|
@@ -34,7 +38,6 @@ module Webpack
|
|
|
34
38
|
end
|
|
35
39
|
end
|
|
36
40
|
|
|
37
|
-
|
|
38
41
|
def manifest
|
|
39
42
|
if Webpack::RailsHelper::Config.dev_server_enabled?
|
|
40
43
|
# Always reload from dev_server as manifest may change
|
|
@@ -13,8 +13,10 @@ module Webpack
|
|
|
13
13
|
include Webpack::RailsHelper::Helper
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if ::Rails.configuration.eager_load
|
|
17
|
+
Webpack::RailsHelper::Manifest.load_manifest
|
|
18
|
+
Spring.after_fork { Webpack::RailsHelper::Manifest.load_manifest } if defined?(Spring)
|
|
19
|
+
end
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
config.webpack = ActiveSupport::OrderedOptions.new
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: webpack-rails-helper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Ritz
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-10-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: railties
|