minipack 0.3.3 → 0.3.4
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/CHANGELOG.md +6 -0
- data/lib/minipack/helper.rb +7 -3
- data/lib/minipack/manifest.rb +17 -1
- data/lib/minipack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d47e53dced7bb9112a2b25cc87e72afc8b46d6f8e0094e3e45ebad30658025b3
|
4
|
+
data.tar.gz: 501f45243494b6eb9d0923d77f5556176b37b9b285c22222d734a46aba14b6c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8657e7b6dc81587b777a8308bf92df6167ba941b778b2549dc52b4e013ea28aeb414a97142597aaf88d7999f3868cf502e123dd7b9fe086020c249e831615883
|
7
|
+
data.tar.gz: 15c4be737e9477a05ae44bcb3873761ccea785159930f2c07ac9604d0d86c5670fd4f4b6ea78279de381776f10dea7d662d2690222faa59baa1b8e2546d8526f
|
data/CHANGELOG.md
CHANGED
data/lib/minipack/helper.rb
CHANGED
@@ -41,7 +41,9 @@ module Minipack::Helper
|
|
41
41
|
# <%= javascript_bundles_with_chunks_tag 'calendar' %>
|
42
42
|
# <%= javascript_bundles_with_chunks_tag 'map' %>
|
43
43
|
def javascript_bundles_with_chunks_tag(*names, manifest: nil, **options)
|
44
|
-
|
44
|
+
sources_from_manifest_entrypoints(names, 'js', key: manifest).map { |entry|
|
45
|
+
javascript_include_tag(entry.path, **options_for(entry, options))
|
46
|
+
}.join("\n").html_safe
|
45
47
|
end
|
46
48
|
|
47
49
|
# Examples:
|
@@ -76,7 +78,9 @@ module Minipack::Helper
|
|
76
78
|
# <%= stylesheet_bundles_with_chunks_tag 'map' %>
|
77
79
|
def stylesheet_bundles_with_chunks_tag(*names, manifest: nil, **options)
|
78
80
|
if Minipack.configuration.extract_css?
|
79
|
-
|
81
|
+
sources_from_manifest_entrypoints(names, 'css', key: manifest).map { |entry|
|
82
|
+
stylesheet_link_tag(entry.path, **options_for(entry, options))
|
83
|
+
}.join("\n").html_safe
|
80
84
|
end
|
81
85
|
end
|
82
86
|
|
@@ -101,7 +105,7 @@ module Minipack::Helper
|
|
101
105
|
|
102
106
|
def sources_from_manifest_entrypoints(names, type, key: nil)
|
103
107
|
manifest = get_manifest_by_key(key)
|
104
|
-
names.map { |name| manifest.lookup_pack_with_chunks!(name, type: type).entries
|
108
|
+
names.map { |name| manifest.lookup_pack_with_chunks!(name, type: type).entries }.flatten.uniq
|
105
109
|
end
|
106
110
|
|
107
111
|
def get_manifest_by_key(key = nil)
|
data/lib/minipack/manifest.rb
CHANGED
@@ -51,7 +51,12 @@ module Minipack
|
|
51
51
|
manifest_pack_type = manifest_type(name, type)
|
52
52
|
manifest_pack_name = manifest_name(name, manifest_pack_type)
|
53
53
|
paths = data['entrypoints']&.dig(manifest_pack_name, manifest_pack_type) || handle_missing_entry(name)
|
54
|
-
|
54
|
+
|
55
|
+
entries = data['entrypoints']&.dig(manifest_pack_name, manifest_pack_type).map do |source|
|
56
|
+
entry_from_source(source) || handle_missing_entry(name)
|
57
|
+
end
|
58
|
+
|
59
|
+
ChunkGroup.new(entries)
|
55
60
|
end
|
56
61
|
|
57
62
|
def lookup!(name)
|
@@ -122,5 +127,16 @@ module Minipack
|
|
122
127
|
#{JSON.pretty_generate(@data)}
|
123
128
|
MSG
|
124
129
|
end
|
130
|
+
|
131
|
+
# Find an entry by its source
|
132
|
+
#
|
133
|
+
# @param [String] source
|
134
|
+
# @return [Minipack::Entry,nil]
|
135
|
+
def entry_from_source(source)
|
136
|
+
entry = assets.find { |entry| entry.is_a?(String) ? entry == source : entry['src'] == source }
|
137
|
+
return unless entry
|
138
|
+
entry.is_a?(String) ? Entry.new(entry) : Entry.new(entry['src'], integrity: entry['integrity'])
|
139
|
+
end
|
125
140
|
end
|
126
141
|
end
|
142
|
+
|
data/lib/minipack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minipack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nobuhiro Nikushi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|