webpacker_lite 0.0.4 → 0.0.5

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: acbe663d2b9227e13989ad2bea4b7bc11a4d3b71
4
- data.tar.gz: 23e10ed84e9ea19bc2472a11ac1008f7d2c6360d
3
+ metadata.gz: 2f0469eadde12c4a8d39d83f413319838a5f7f25
4
+ data.tar.gz: d5acc328df7ff1453b85fe5ffd1eeee4cb543dc9
5
5
  SHA512:
6
- metadata.gz: a5efa273e7ca3edae5bdeedb13f970b429770d2ab15c3b24a520c2d2712d278eab1b048f18d68966fc5f929dfa74962aaba85be015ecb4527d8174a6ccedb2a0
7
- data.tar.gz: 3dc5f3a33d861dc6d95d58ff0e80a1384b865a328d6597816f61c16ea8f23e641c86f5b6d9a35d6d4d6910a842220af96e3f5a64282c5fbbbf512f2a6b2cbba6
6
+ metadata.gz: 7387488ad990a6bb23b8598e3023ff68d398b08b7352fb276cb792b4528cfd4943b12400dd1af999d86bd1ca54a7fae6640cc8c0403039bdd088ec5b9690f222
7
+ data.tar.gz: 04eaa505cc7645645c14b051002cdace7604dd227c2934979aadbe964449be8608e6ff2570efb6396026f2b85145bf4a3a5085e37de73c27630369dcb2551fe6
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  /.bundle
2
2
  node_modules
3
+ pkg
data/README.md CHANGED
@@ -1,17 +1,16 @@
1
1
  # Webpacker Lite
2
- ![travis-ci status](https://api.travis-ci.org/rails/webpacker_lite.svg?branch=master)
3
- [![node.js](https://img.shields.io/badge/node-%3E%3D%206.4.0-brightgreen.svg)](https://nodejs.org/en/)
4
2
  [![Gem](https://img.shields.io/gem/v/webpacker_lite.svg)](https://github.com/shakacode/webpacker_lite)
5
3
 
6
4
  Webpacker Lite provides the webpack enabled asset helpers from [Webpacker](https://github.com/rails/webpacker).
7
5
  [React on Rails](https://github.com/shakacode/react_on_rails) will soon support using Webpacker Lite.
8
6
 
7
+ # NEWS
8
+ * 2017-04-09: React on Rails 7.0.0 beta work to include webpacker_lite gem has begun. See [#786](https://github.com/shakacode/react_on_rails/issues/786
9
+
9
10
  ## Prerequisites
10
11
 
11
- * Ruby 2.2+
12
+ * Ruby 2+
12
13
  * Rails 4.2+
13
- * Node.js 6.4.0+
14
- * Yarn
15
14
 
16
15
  ## Installation
17
16
 
@@ -12,6 +12,10 @@ class WebpackerLite::Env < WebpackerLite::FileLoader
12
12
  current == "development"
13
13
  end
14
14
 
15
+ def hot_loading?
16
+ ENV["REACT_ON_RAILS_ENV"] == "HOT"
17
+ end
18
+
15
19
  def file_path
16
20
  Rails.root.join("config", "webpack", "paths.yml")
17
21
  end
@@ -1,4 +1,5 @@
1
1
  require "webpacker_lite/manifest"
2
+ require "webpacker_lite/env"
2
3
 
3
4
  module WebpackerLite::Helper
4
5
  # Computes the full path for a given webpacker asset.
@@ -30,20 +31,59 @@ module WebpackerLite::Helper
30
31
  javascript_include_tag(WebpackerLite::Manifest.lookup("#{name}#{compute_asset_extname(name, type: :javascript)}"), **options)
31
32
  end
32
33
 
33
- # Creates a link tag that references the named pack file, as compiled by Webpack per the entries list
34
- # in config/webpack/shared.js. By default, this list is auto-generated to match everything in
35
- # app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
34
+ # Creates a link tag that references the named pack file(s), as compiled by Webpack per the entries list
35
+ # in client/webpack.client.base.config.js.
36
36
  #
37
37
  # Examples:
38
38
  #
39
- # # In development mode:
39
+ # # In production mode:
40
40
  # <%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
41
- # <link rel="stylesheet" media="screen" href="/packs/calendar.css" data-turbolinks-track="reload" />
41
+ # <link rel="stylesheet" media="screen" href="/public/webpack/production/calendar-1016838bab065ae1e122.css" data-turbolinks-track="reload" />
42
42
  #
43
- # # In production mode:
43
+ # # In development mode:
44
44
  # <%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
45
- # <link rel="stylesheet" media="screen" href="/packs/calendar-1016838bab065ae1e122.css" data-turbolinks-track="reload" />
46
- def stylesheet_pack_tag(name, **options)
47
- stylesheet_link_tag(WebpackerLite::Manifest.lookup("#{name}#{compute_asset_extname(name, type: :stylesheet)}"), **options)
45
+ # <link rel="stylesheet" media="screen" href="/public/webpack/development/calendar.css" data-turbolinks-track="reload" />
46
+ #
47
+ # The key options are `static` and `hot` which specify what you want for static vs. hot. Both of
48
+ # these params are optional, and support either a single value, or an array.
49
+ #
50
+ # static vs. hot is picked based on whether
51
+ # ENV["REACT_ON_RAILS_ENV"] == "HOT"
52
+ # <%= stylesheet_pack_tag(static: 'application_static',
53
+ # hot: 'application_non_webpack',
54
+ # media: 'all',
55
+ # 'data-turbolinks-track' => "reload") %>
56
+ #
57
+ # <!-- These do not use turbolinks, so no data-turbolinks-track -->
58
+ # <!-- This is to load the hot assets. -->
59
+ # <%= stylesheet_pack_tag(hot: ['app', 'vendor']) %>
60
+ #
61
+ # <!-- These do use turbolinks -->
62
+ # <%= stylesheet_pack_tag(static: 'application_static',
63
+ # hot: 'application_non_webpack',
64
+ # 'data-turbolinks-track': 'reload') %>
65
+ #
66
+
67
+ def stylesheet_pack_tag(*args, **kwargs)
68
+ manifested_names = []
69
+ default_case = args.any?
70
+ if default_case
71
+ args.flatten!
72
+ manifested_names += get_manifests(args)
73
+ end
74
+ asset_type = WebpackerLite::Env.hot_loading? ? :hot : :static
75
+ names = Array(kwargs[asset_type])
76
+ manifested_names += get_manifests(names)
77
+
78
+ options = kwargs.delete_if { |key, _value| %i(hot static).include?(key) }
79
+ stylesheet_link_tag(*manifested_names, options)
80
+ end
81
+
82
+ private
83
+
84
+ def get_manifests(names)
85
+ names.map do |name|
86
+ WebpackerLite::Manifest.lookup("#{name}#{compute_asset_extname(name, type: :stylesheet)}")
87
+ end
48
88
  end
49
89
  end
@@ -1,3 +1,3 @@
1
1
  module WebpackerLite
2
- VERSION = "0.0.4".freeze
2
+ VERSION = "0.0.5".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson, Justin Gordon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-10 00:00:00.000000000 Z
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport