webpacker_lite 0.0.4 → 0.0.5
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 +4 -5
- data/lib/webpacker_lite/env.rb +4 -0
- data/lib/webpacker_lite/helper.rb +49 -9
- data/lib/webpacker_lite/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: 2f0469eadde12c4a8d39d83f413319838a5f7f25
|
4
|
+
data.tar.gz: d5acc328df7ff1453b85fe5ffd1eeee4cb543dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7387488ad990a6bb23b8598e3023ff68d398b08b7352fb276cb792b4528cfd4943b12400dd1af999d86bd1ca54a7fae6640cc8c0403039bdd088ec5b9690f222
|
7
|
+
data.tar.gz: 04eaa505cc7645645c14b051002cdace7604dd227c2934979aadbe964449be8608e6ff2570efb6396026f2b85145bf4a3a5085e37de73c27630369dcb2551fe6
|
data/.gitignore
CHANGED
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
|
12
|
+
* Ruby 2+
|
12
13
|
* Rails 4.2+
|
13
|
-
* Node.js 6.4.0+
|
14
|
-
* Yarn
|
15
14
|
|
16
15
|
## Installation
|
17
16
|
|
data/lib/webpacker_lite/env.rb
CHANGED
@@ -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
|
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
|
39
|
+
# # In production mode:
|
40
40
|
# <%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
|
41
|
-
# <link rel="stylesheet" media="screen" href="/
|
41
|
+
# <link rel="stylesheet" media="screen" href="/public/webpack/production/calendar-1016838bab065ae1e122.css" data-turbolinks-track="reload" />
|
42
42
|
#
|
43
|
-
# # In
|
43
|
+
# # In development mode:
|
44
44
|
# <%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
|
45
|
-
# <link rel="stylesheet" media="screen" href="/
|
46
|
-
|
47
|
-
|
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
|
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
|
+
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-
|
11
|
+
date: 2017-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|