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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebb28f3859580b2883942fbfbb21b4f5bb2c35db
4
- data.tar.gz: 564cdf5f246f979fbd3e7dee39b4c89e71386022
3
+ metadata.gz: eff1373c5bf4eb7d1ced1c3620173475f4e69c72
4
+ data.tar.gz: 8f828bea26707149d73f8d1bdea2e6645d49bb36
5
5
  SHA512:
6
- metadata.gz: 5dcba41e51e5a25ed51c0fdab391aec43ed6b75f8f6b5c94b42a06a02be5637ebb856d92de9731e8a328fbfa05c1dfc9d2474e33945595c8113ea901e356e41b
7
- data.tar.gz: 5a75ec63cb3513225e031fbef86c7f810ff2893c266a572918befbd438385615deff037710f8439685674a174f1f2d654ced721b502ca0d11e04929cda1d429a
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. This
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
- * Javascript tag:
107
+ * Stylesheet tag:
108
108
 
109
109
  ```
110
110
  stylesheet_webpack_tag(*names, **options)
@@ -1,10 +1,5 @@
1
1
  module Webpack
2
2
  module RailsHelper
3
- extend self
4
-
5
- def bootstrap
6
- Webpack::RailsHelper::Manifest.load_manifest
7
- end
8
3
  end
9
4
  end
10
5
 
@@ -7,18 +7,11 @@ class Webpack::RailsHelper::Config
7
7
  end
8
8
 
9
9
  def asset_prefix
10
- @asset_prefix ||=
11
- if config_root.dev_server.enabled
12
- port = config_root.dev_server.port
13
- protocol = config_root.dev_server.https ? 'https' : 'http'
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
- Webpack::RailsHelper.bootstrap
17
- Spring.after_fork { Webpack::RailsHelper.bootstrap } if defined?(Spring)
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
@@ -1,5 +1,5 @@
1
1
  module Webpack
2
2
  module RailsHelper
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
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.1.1
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-08-06 00:00:00.000000000 Z
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties