jekyll-minibundle 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +162 -63
- data/README.md +62 -57
- data/Rakefile +27 -14
- data/jekyll-minibundle.gemspec +15 -13
- data/lib/jekyll/minibundle.rb +2 -0
- data/lib/jekyll/minibundle/asset_bundle.rb +16 -10
- data/lib/jekyll/minibundle/asset_file_drop.rb +5 -2
- data/lib/jekyll/minibundle/asset_file_properties.rb +2 -0
- data/lib/jekyll/minibundle/asset_file_registry.rb +9 -7
- data/lib/jekyll/minibundle/asset_stamp.rb +2 -0
- data/lib/jekyll/minibundle/asset_tag_markup.rb +6 -4
- data/lib/jekyll/minibundle/bundle_file.rb +8 -0
- data/lib/jekyll/minibundle/development_file.rb +4 -0
- data/lib/jekyll/minibundle/development_file_collection.rb +2 -0
- data/lib/jekyll/minibundle/environment.rb +5 -1
- data/lib/jekyll/minibundle/exceptions.rb +2 -0
- data/lib/jekyll/minibundle/files.rb +2 -0
- data/lib/jekyll/minibundle/hashes.rb +3 -0
- data/lib/jekyll/minibundle/log.rb +3 -1
- data/lib/jekyll/minibundle/mini_bundle_block.rb +8 -1
- data/lib/jekyll/minibundle/mini_stamp_tag.rb +3 -1
- data/lib/jekyll/minibundle/stamp_file.rb +4 -0
- data/lib/jekyll/minibundle/variable_template.rb +15 -12
- data/lib/jekyll/minibundle/variable_template_registry.rb +2 -0
- data/lib/jekyll/minibundle/version.rb +3 -1
- data/test/fixture/site/_bin/remove_comments +1 -0
- data/test/fixture/site/_bin/with_count +1 -0
- data/test/fixture/site/_config.yml +2 -1
- data/test/integration/minibundle_development_mode_test.rb +115 -29
- data/test/integration/minibundle_production_mode_test.rb +157 -69
- data/test/integration/ministamp_development_mode_test.rb +4 -2
- data/test/integration/ministamp_production_mode_test.rb +6 -4
- data/test/integration/static_files_as_asset_sources_test.rb +6 -4
- data/test/support/assertions.rb +2 -0
- data/test/support/fixture_config.rb +14 -12
- data/test/support/static_file_config.rb +18 -16
- data/test/support/test_case.rb +5 -3
- data/test/unit/asset_bundle_test.rb +14 -12
- data/test/unit/asset_file_drop_test.rb +4 -3
- data/test/unit/asset_file_registry_test.rb +16 -19
- data/test/unit/asset_tag_markup_test.rb +8 -6
- data/test/unit/bundle_file_properties_test.rb +6 -4
- data/test/unit/bundle_file_writing_test.rb +6 -4
- data/test/unit/development_file_properties_test.rb +5 -3
- data/test/unit/development_file_writing_test.rb +4 -2
- data/test/unit/environment_test.rb +6 -4
- data/test/unit/files_test.rb +3 -1
- data/test/unit/hashes_test.rb +3 -1
- data/test/unit/jekyll_static_file_api_test.rb +13 -9
- data/test/unit/mini_bundle_block_test.rb +42 -35
- data/test/unit/mini_stamp_tag_test.rb +4 -2
- data/test/unit/stamp_file_properties_test.rb +5 -3
- data/test/unit/stamp_file_writing_test.rb +4 -2
- data/test/unit/variable_template_test.rb +8 -8
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 997ab9ce6b810501fe2ef0177f8982cf5cae5b7f98871ca84c160e15dd90852a
|
4
|
+
data.tar.gz: eeedab2288ea816ffb94568ddc80a5a4a560e4701bb7b5a9c07875100e191338
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cc289086a2222a0f1e67df53135143da8248a9989e8ebd02839ab10260e2090ab83198f1b1cf271a6792a566d9b2182b28e62cb89cb62a4b42597a99a10bb60
|
7
|
+
data.tar.gz: 90af2278865d5be704c6d36263b9df905d61d28d28914f7584b10640770fb3af7fc129d3c798abcddda57b8d713193df17b4b22ddf9b1c70eb4ffcb0638bb29b
|
data/CHANGELOG.md
CHANGED
@@ -1,27 +1,57 @@
|
|
1
|
-
#
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
This project adheres to [Semantic Versioning].
|
4
|
+
|
5
|
+
## [Unreleased]
|
6
|
+
|
7
|
+
## [v3.0.0] - 2020-09-06
|
8
|
+
|
9
|
+
No functional changes, only minor refactorings since v2.2.0. Dropping
|
10
|
+
support for Ruby MRI < 2.4 causes major version bump.
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
* Increase test coverage.
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
* Hygienic refactorings: use frozen string literals, prefer squiggly
|
19
|
+
heredocs over non-squiggly ones, adhere to the RuboCop linter.
|
20
|
+
|
21
|
+
### Removed
|
22
|
+
|
23
|
+
* Drop support for Ruby MRI versions below 2.4.
|
24
|
+
|
25
|
+
## [v2.2.0] - 2017-03-10
|
26
|
+
|
27
|
+
### Added
|
7
28
|
|
8
29
|
* Add support for separating asset destination path from the generated
|
9
30
|
asset URL. See `render_basename_only` option of `ministamp` tag and
|
10
31
|
`destination_baseurl` option of `minibundle` block.
|
11
32
|
|
12
|
-
|
33
|
+
### Changed
|
13
34
|
|
35
|
+
* Treat `ministamp` tag's argument as YAML, resulting either in String
|
36
|
+
or Hash type of argument after YAML parsing. If argument is of Hash
|
37
|
+
type, render values with Liquid-like templating support, allowing
|
38
|
+
rendering Liquid variables. This change is backwards compatible.
|
39
|
+
* Escape the URLs generated by `ministamp` tag and `minibundle` block.
|
14
40
|
* Quote paths in error messages more consistently.
|
15
|
-
|
16
41
|
* Show better error messages in various situations when asset source
|
17
42
|
file does not exist.
|
18
|
-
|
19
43
|
* Compatibility: conform to Jekyll 3.4.2's StaticFile public API.
|
20
44
|
|
21
|
-
|
45
|
+
## [v2.1.2] - 2017-02-28
|
22
46
|
|
23
|
-
|
24
|
-
|
47
|
+
### Added
|
48
|
+
|
49
|
+
* Show bundle destination path in bundling log message.
|
50
|
+
|
51
|
+
### Fixed
|
52
|
+
|
53
|
+
* Remove unnecessary '.' path component from asset destination path.
|
54
|
+
This manifested when the asset destination had no subdirectory.
|
25
55
|
Affects `ministamp` tag and `minibundle` block.
|
26
56
|
|
27
57
|
Example situation:
|
@@ -41,131 +71,159 @@
|
|
41
71
|
```
|
42
72
|
<link href="/site-6a204bd89f3c8348afd5c77c717a097a.css" rel="stylesheet">
|
43
73
|
```
|
74
|
+
* Related to above: Don't let Jekyll's watch mode (auto-regeneration)
|
75
|
+
remove asset from generated site directory when asset destination path
|
76
|
+
has no subdirectory.
|
44
77
|
|
45
|
-
|
46
|
-
(auto-regeneration) remove asset from generated site directory when
|
47
|
-
asset destination path has no subdirectory.
|
78
|
+
## [v2.1.1] - 2017-01-14
|
48
79
|
|
49
|
-
|
80
|
+
### Changed
|
81
|
+
|
82
|
+
* Compatibility: conform to Jekyll 3.3's StaticFile public API.
|
50
83
|
|
51
|
-
|
84
|
+
### Fixed
|
52
85
|
|
53
86
|
* Fix the file permissions of `minibundle` block's output file to
|
54
87
|
respect umask setting. Bug report from Alfonse Surigao.
|
55
88
|
|
56
|
-
|
89
|
+
## [v2.1.0] - 2016-05-04
|
57
90
|
|
58
|
-
|
91
|
+
### Changed
|
59
92
|
|
60
93
|
* Allow attributes without values. Useful for `async` attribute, for
|
61
94
|
example. Pull Request #7 by Sam (@codewisdom).
|
62
95
|
|
96
|
+
### Fixed
|
97
|
+
|
63
98
|
* Ensure attribute value conversion to string.
|
64
99
|
|
65
|
-
|
100
|
+
## [v2.0.1] - 2016-04-06
|
101
|
+
|
102
|
+
### Fixed
|
66
103
|
|
67
104
|
* Fix Jekyll version requirement check to be more reliable.
|
68
105
|
|
69
|
-
|
106
|
+
## [v2.0.0] - 2016-04-01
|
70
107
|
|
71
|
-
|
108
|
+
### Changed
|
72
109
|
|
73
110
|
* Remove unused asset cache entries and temporary files when Jekyll
|
74
111
|
rebuilds the site.
|
75
|
-
|
76
112
|
* Document a known caveat: the plugin doesn't work with Jekyll's
|
77
113
|
incremental rebuild feature.
|
78
114
|
|
79
|
-
|
115
|
+
### Removed
|
116
|
+
|
117
|
+
* Drop support for Jekyll versions below 3.
|
118
|
+
|
119
|
+
## [v1.6.0] - 2016-03-26
|
120
|
+
|
121
|
+
### Changed
|
80
122
|
|
81
123
|
* Log the last 2000 bytes of minifier's STDOUT output if the minifier
|
82
124
|
command fails. Pull Request #6 by Martin Nordholts (@Enselic).
|
83
|
-
|
84
125
|
* Allow prepending base URL for the destination path of `minibundle`
|
85
126
|
block.
|
86
127
|
|
128
|
+
### Removed
|
129
|
+
|
87
130
|
* Drop Ruby MRI 1.9 support because Jekyll 3 does not support it.
|
88
131
|
|
132
|
+
### Fixed
|
133
|
+
|
89
134
|
* Fix issues in asset reloading in Jekyll's watch (auto-regeneration)
|
90
135
|
mode, doing bundling and asset fingerprinting again.
|
91
136
|
|
92
|
-
|
137
|
+
## [v1.5.1] - 2015-01-29
|
138
|
+
|
139
|
+
### Changed
|
93
140
|
|
94
141
|
* Improve future compatibility with Jekyll. Minibundle has classes
|
95
142
|
adhering to `Jekyll::StaticFile` interface, and some method
|
96
143
|
implementations of the interface were missing.
|
97
|
-
|
98
144
|
* Small refactorings and test improvements.
|
99
145
|
|
100
|
-
|
146
|
+
## [v1.5.0] - 2014-07-27
|
147
|
+
|
148
|
+
### Added
|
101
149
|
|
102
150
|
* Support minifier command specification in `_config.yml` and inside
|
103
151
|
`minibundle` block. Issue #4 by Phillip Smith (@phillipadsmith).
|
104
|
-
|
105
152
|
* Support enabling development mode from `_config.yml`.
|
106
|
-
|
107
153
|
* Add argument validation to `minibundle` block and `ministamp` tag.
|
108
|
-
|
109
154
|
* Document how to load the gem with Jekyll's `gems` config setting.
|
110
155
|
|
111
|
-
|
156
|
+
## [v1.4.6] - 2014-05-10
|
157
|
+
|
158
|
+
### Changed
|
112
159
|
|
113
160
|
* Handle compatibility issues with safe_yaml and logger flexibly. This
|
114
161
|
should allow using the plugin with Jekyll 1.0 and 2.0.
|
115
162
|
|
116
|
-
|
163
|
+
## [v1.4.5] - 2014-05-10
|
164
|
+
|
165
|
+
### Changed
|
117
166
|
|
118
167
|
* Use SafeYAML to load user input from `minibundle` block for
|
119
168
|
consistent behavior with Jekyll and for security.
|
120
|
-
|
121
169
|
* Clean log messages: show relative paths when bundling assets.
|
122
170
|
|
171
|
+
### Fixed
|
172
|
+
|
123
173
|
* Add missing implementations of `relative_path` and `to_liquid`
|
124
174
|
methods from Jekyll's StaticFile API (introduced in Jekyll v1.5.0),
|
125
175
|
allowing Minibundle to behave better with other Jekyll
|
126
176
|
plugins. Issue #3 by Michael Rose (@mmistakes).
|
127
|
-
|
128
177
|
* Fix Ruby deprecation warnings (use `File.exist?` instead of
|
129
178
|
`File.exists?`).
|
130
179
|
|
131
|
-
|
180
|
+
## [v1.4.4] - 2014-01-16
|
181
|
+
|
182
|
+
### Changed
|
132
183
|
|
133
184
|
* Conserve memory when calculating fingerprint for an asset.
|
134
185
|
Previously, we read the whole asset file into memory and then
|
135
186
|
calculated the MD5 digest. This is bad for big assets. Now, we read
|
136
187
|
the file in chunks.
|
137
188
|
|
138
|
-
|
189
|
+
## [v1.4.3] - 2014-01-16
|
139
190
|
|
140
|
-
|
191
|
+
### Changed
|
141
192
|
|
142
193
|
* Loosen version constraints for development gem dependencies.
|
143
|
-
|
144
194
|
* Clarify documentation.
|
195
|
+
* Minor internal state handling improvements.
|
196
|
+
* Clarify tests, increase test coverage.
|
145
197
|
|
198
|
+
### Fixed
|
199
|
+
|
200
|
+
* Do not leak read pipe file descriptor upon minifier command failure.
|
146
201
|
* Fix some Ruby coding style issues.
|
147
202
|
|
148
|
-
|
203
|
+
## [v1.4.2] - 2013-12-28
|
149
204
|
|
150
|
-
|
205
|
+
### Changed
|
151
206
|
|
152
|
-
|
207
|
+
* Separate tags produced by `minibundle` in development mode with
|
208
|
+
newlines.
|
209
|
+
* Clarify tests, increase coverage.
|
210
|
+
|
211
|
+
### Fixed
|
153
212
|
|
154
213
|
* Ensure touching asset source triggers destination write. This was an
|
155
214
|
unintentional edge case earlier. Now the behavior of touching the
|
156
215
|
asset source is consistent with when changing the contents of the
|
157
216
|
source.
|
158
217
|
|
159
|
-
|
160
|
-
newlines.
|
161
|
-
|
162
|
-
* Clarify tests, increase coverage.
|
218
|
+
## [v1.4.1] - 2013-12-27
|
163
219
|
|
164
|
-
|
220
|
+
### Fixed
|
165
221
|
|
166
222
|
* Add missing files to gem package.
|
167
223
|
|
168
|
-
|
224
|
+
## [v1.4.0] - 2013-12-27
|
225
|
+
|
226
|
+
### Fixed
|
169
227
|
|
170
228
|
* Fix bug causing exception to be thrown when `ministamp` or
|
171
229
|
`minibundle` is called twice with same asset source argument. Allow
|
@@ -173,55 +231,96 @@
|
|
173
231
|
(remove the restriction introduced in 1.3.0). Issue #2 by Austin
|
174
232
|
Grigg (@agrigg).
|
175
233
|
|
176
|
-
|
234
|
+
## [v1.3.0] - 2013-12-25
|
235
|
+
|
236
|
+
### Changed
|
237
|
+
|
238
|
+
* Upgrade development dependencies.
|
239
|
+
|
240
|
+
### Fixed
|
177
241
|
|
178
242
|
* Disallow handling asset source files that are already static files
|
179
243
|
in Jekyll. Otherwise, we would potentially get to inconsistencies in
|
180
244
|
Jekyll's watch mode. See "Jekyll static file restriction" in
|
181
245
|
README.md. Issue #2 by Austin Grigg (@agrigg).
|
182
246
|
|
183
|
-
|
247
|
+
## [v1.2.0] - 2013-09-29
|
184
248
|
|
185
|
-
|
249
|
+
### Changed
|
186
250
|
|
187
251
|
* If Jekyll's logger is available, use it for nice output when bundling.
|
188
|
-
|
189
252
|
* Upgrade development dependencies.
|
190
|
-
|
191
253
|
* Simplify `BundleFile` class implementation.
|
192
254
|
|
193
|
-
|
255
|
+
## [v1.1.0] - 2013-02-27
|
256
|
+
|
257
|
+
### Added
|
194
258
|
|
195
259
|
* `ministamp` tag omits fingerprint in development mode.
|
196
260
|
|
197
|
-
|
261
|
+
### Changed
|
198
262
|
|
263
|
+
* Clarify documentation.
|
199
264
|
* Comply with (Gemnasium) conventions for changelogs. Pull Request #1
|
200
265
|
by Teemu Matilainen (@tmatilai).
|
201
266
|
|
202
|
-
|
267
|
+
### Fixed
|
203
268
|
|
204
|
-
*
|
269
|
+
* Don't bundle assets when nonrelated files change.
|
270
|
+
* Don't bundle assets twice upon startup.
|
205
271
|
|
206
|
-
|
272
|
+
## [v1.0.0] - 2013-02-15
|
273
|
+
|
274
|
+
### Added
|
207
275
|
|
208
276
|
* Add development mode, where `minibundle` block will copy each asset
|
209
277
|
as-is to the destination directory.
|
210
278
|
|
211
|
-
|
279
|
+
### Changed
|
212
280
|
|
281
|
+
* Clarify documentation.
|
213
282
|
* Increase test coverage.
|
214
283
|
|
215
|
-
|
284
|
+
## [v0.2.0] - 2012-12-15
|
216
285
|
|
217
|
-
|
286
|
+
### Added
|
218
287
|
|
219
288
|
* Add semicolons between each JavaScript asset in bundling.
|
220
|
-
|
221
289
|
* Show error in page output if asset bundling command failed.
|
222
290
|
|
223
|
-
|
291
|
+
### Changed
|
224
292
|
|
225
|
-
*
|
293
|
+
* Escape the values of custom attributes given in `minibundle` block.
|
294
|
+
|
295
|
+
## [v0.1.0] - 2012-12-07
|
296
|
+
|
297
|
+
### Added
|
226
298
|
|
299
|
+
* Add `ministamp` tag and `minibundle` block for Jekyll.
|
227
300
|
* First release.
|
301
|
+
|
302
|
+
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html
|
303
|
+
[Unreleased]: https://github.com/tkareine/jekyll-minibundle/compare/v3.0.0...HEAD
|
304
|
+
[v3.0.0]: https://github.com/tkareine/jekyll-minibundle/compare/v2.2.0...v3.0.0
|
305
|
+
[v2.2.0]: https://github.com/tkareine/jekyll-minibundle/compare/v2.1.2...v2.2.0
|
306
|
+
[v2.1.2]: https://github.com/tkareine/jekyll-minibundle/compare/v2.1.1...v2.1.2
|
307
|
+
[v2.1.1]: https://github.com/tkareine/jekyll-minibundle/compare/v2.1.0...v2.1.1
|
308
|
+
[v2.1.0]: https://github.com/tkareine/jekyll-minibundle/compare/v2.0.1...v2.1.0
|
309
|
+
[v2.0.1]: https://github.com/tkareine/jekyll-minibundle/compare/v2.0.0...v2.0.1
|
310
|
+
[v2.0.0]: https://github.com/tkareine/jekyll-minibundle/compare/v1.6.0...v2.0.0
|
311
|
+
[v1.6.0]: https://github.com/tkareine/jekyll-minibundle/compare/v1.5.1...v1.6.0
|
312
|
+
[v1.5.1]: https://github.com/tkareine/jekyll-minibundle/compare/v1.5.0...v1.5.1
|
313
|
+
[v1.5.0]: https://github.com/tkareine/jekyll-minibundle/compare/v1.4.6...v1.5.0
|
314
|
+
[v1.4.6]: https://github.com/tkareine/jekyll-minibundle/compare/v1.4.5...v1.4.6
|
315
|
+
[v1.4.5]: https://github.com/tkareine/jekyll-minibundle/compare/v1.4.4...v1.4.5
|
316
|
+
[v1.4.4]: https://github.com/tkareine/jekyll-minibundle/compare/v1.4.3...v1.4.4
|
317
|
+
[v1.4.3]: https://github.com/tkareine/jekyll-minibundle/compare/v1.4.2...v1.4.3
|
318
|
+
[v1.4.2]: https://github.com/tkareine/jekyll-minibundle/compare/v1.4.1...v1.4.2
|
319
|
+
[v1.4.1]: https://github.com/tkareine/jekyll-minibundle/compare/v1.4.0...v1.4.1
|
320
|
+
[v1.4.0]: https://github.com/tkareine/jekyll-minibundle/compare/v1.3.0...v1.4.0
|
321
|
+
[v1.3.0]: https://github.com/tkareine/jekyll-minibundle/compare/v1.2.0...v1.3.0
|
322
|
+
[v1.2.0]: https://github.com/tkareine/jekyll-minibundle/compare/v1.1.0...v1.2.0
|
323
|
+
[v1.1.0]: https://github.com/tkareine/jekyll-minibundle/compare/v1.0.0...v1.1.0
|
324
|
+
[v1.0.0]: https://github.com/tkareine/jekyll-minibundle/compare/v0.2.0...v1.0.0
|
325
|
+
[v0.2.0]: https://github.com/tkareine/jekyll-minibundle/compare/v0.1.0...v0.2.0
|
326
|
+
[v0.1.0]: https://github.com/tkareine/jekyll-minibundle/releases/tag/v0.1.0
|
data/README.md
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
# Jekyll Minibundle plugin
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
[![Gem version](https://badge.fury.io/rb/jekyll-minibundle.svg)][MinibundleGem]
|
4
|
+
[![CI](https://github.com/tkareine/jekyll-minibundle/workflows/CI/badge.svg)][MinibundleCI]
|
5
|
+
|
6
|
+
A straightforward asset bundling plugin for [Jekyll], utilizing external
|
7
|
+
minification tool of your choice. It provides asset concatenation for
|
8
|
+
bundling and asset fingerprinting with MD5 digest for cache busting.
|
7
9
|
|
8
10
|
There are no runtime dependencies, except for the minification tool used
|
9
11
|
for bundling (fingerprinting has no dependencies).
|
10
12
|
|
11
|
-
The plugin requires Jekyll version 3.
|
12
|
-
2.
|
13
|
+
The plugin requires Jekyll version 3 or 4. It is tested with Ruby MRI
|
14
|
+
2.4 and later.
|
13
15
|
|
14
16
|
The plugin works with Jekyll's watch mode (auto-regeneration, Jekyll
|
15
17
|
option `--watch`), but not with incremental feature enabled (Jekyll
|
16
18
|
option `--incremental`).
|
17
19
|
|
18
|
-
[![Gem version](https://badge.fury.io/rb/jekyll-minibundle.svg)][MinibundleGem]
|
19
|
-
[![Build status](https://secure.travis-ci.org/tkareine/jekyll-minibundle.svg)][MinibundleBuild]
|
20
|
-
|
21
20
|
## Features
|
22
21
|
|
23
22
|
There are two features: asset fingerprinting with [MD5 digest][MD5] over
|
@@ -26,10 +25,10 @@ feature.
|
|
26
25
|
|
27
26
|
Asset bundling consists of concatenation and minification. The plugin
|
28
27
|
implements concatenation and leaves choosing the minification tool up to
|
29
|
-
you. [
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
you. [UglifyJS][UglifyJS2] is a good and fast minifier, for example. The
|
29
|
+
plugin connects to the minifier with standard unix pipe, feeding asset
|
30
|
+
file contents to it in desired order via standard input, and reads the
|
31
|
+
result from standard output.
|
33
32
|
|
34
33
|
Why is this good? A fingerprint in asset's path is
|
35
34
|
the [recommended way][GoogleWebFundamentalsHttpCaching] to handle
|
@@ -46,21 +45,25 @@ sources makes asset sizes smaller and thus faster to load over network.
|
|
46
45
|
|
47
46
|
The plugin ships as a [RubyGem][MinibundleGem]. To install:
|
48
47
|
|
49
|
-
|
50
|
-
$ gem install jekyll-minibundle
|
51
|
-
```
|
48
|
+
1. Add the following line to the [Gemfile] of your site:
|
52
49
|
|
53
|
-
|
50
|
+
``` ruby
|
51
|
+
gem 'jekyll-minibundle'
|
52
|
+
```
|
54
53
|
|
55
|
-
|
56
|
-
[configuration file][JekyllConf] of your Jekyll site project
|
57
|
-
(`_config.yml`):
|
54
|
+
2. Run `bundle install`.
|
58
55
|
|
59
|
-
|
60
|
-
|
61
|
-
|
56
|
+
3. Instruct Jekyll to load the gem by adding this line to the
|
57
|
+
[configuration file][JekyllConf] of your site (`_config.yml`):
|
58
|
+
|
59
|
+
``` yaml
|
60
|
+
plugins:
|
61
|
+
- jekyll/minibundle
|
62
|
+
```
|
62
63
|
|
63
|
-
|
64
|
+
(Use the `gems` key instead of `plugins` for Jekyll older than v3.5.0.)
|
65
|
+
|
66
|
+
An alternative to using the `plugins` configuration option is to add
|
64
67
|
`_plugins/minibundle.rb` file to your site project with this line:
|
65
68
|
|
66
69
|
``` ruby
|
@@ -68,12 +71,12 @@ require 'jekyll/minibundle'
|
|
68
71
|
```
|
69
72
|
|
70
73
|
You must allow Jekyll to use custom plugins. That is, do not enable
|
71
|
-
Jekyll's `safe` option.
|
74
|
+
Jekyll's `safe` configuration option.
|
72
75
|
|
73
76
|
### Asset fingerprinting
|
74
77
|
|
75
78
|
If you just want to have an MD5 fingerprint in your asset's path, use
|
76
|
-
`ministamp` [Liquid]
|
79
|
+
`ministamp` [Liquid] tag in a Liquid template file. For example:
|
77
80
|
|
78
81
|
``` liquid
|
79
82
|
<link rel="stylesheet" href="{{ site.baseurl }}/{% ministamp _assets/site.css assets/site.css %}" media="screen, projection">
|
@@ -94,8 +97,8 @@ empty:
|
|
94
97
|
```
|
95
98
|
|
96
99
|
This feature is useful when combined with asset generation tools
|
97
|
-
external to Jekyll. For example, you can configure [Sass]
|
98
|
-
|
100
|
+
external to Jekyll. For example, you can configure [Sass] to take input
|
101
|
+
files from `_assets/styles/*.scss` and to produce output to
|
99
102
|
`_tmp/site.css`. Then, you use `ministamp` tag to copy the file with a
|
100
103
|
fingerprint to Jekyll's site destination directory:
|
101
104
|
|
@@ -105,11 +108,11 @@ fingerprint to Jekyll's site destination directory:
|
|
105
108
|
|
106
109
|
#### `ministamp` call syntax
|
107
110
|
|
108
|
-
The argument for `ministamp` tag must be in [YAML]
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
111
|
+
The argument for `ministamp` tag must be in [YAML] syntax, and parsing
|
112
|
+
the argument as YAML must result either in a String or a Hash. What you
|
113
|
+
saw previously was the argument being parsed as a String; it's
|
114
|
+
effectively a shorthand version of passing the argument as a Hash with
|
115
|
+
certain keys. That is, in the following call:
|
113
116
|
|
114
117
|
``` liquid
|
115
118
|
{% ministamp _tmp/site.css assets/site.css %}
|
@@ -166,10 +169,10 @@ appear. The markup tag contains the path to the bundle file, and the
|
|
166
169
|
Jekyll's site destination directory will have the bundle file at that
|
167
170
|
path. The path will contain an MD5 fingerprint.
|
168
171
|
|
169
|
-
Place `minibundle` [Liquid]
|
170
|
-
|
171
|
-
configuration inside the block in [YAML]
|
172
|
-
|
172
|
+
Place `minibundle` [Liquid] block into the Liquid template file where
|
173
|
+
you want the block's generated markup to appear. Write bundling
|
174
|
+
configuration inside the block in [YAML] syntax. For example, to bundle
|
175
|
+
a set of JavaScript sources:
|
173
176
|
|
174
177
|
``` text
|
175
178
|
{% minibundle js %}
|
@@ -193,7 +196,7 @@ baseurl: ''
|
|
193
196
|
|
194
197
|
minibundle:
|
195
198
|
minifier_commands:
|
196
|
-
js: node_modules/.bin/uglifyjs
|
199
|
+
js: node_modules/.bin/uglifyjs
|
197
200
|
```
|
198
201
|
|
199
202
|
When it's time to render the `minibundle` block, the plugin launches the
|
@@ -244,23 +247,24 @@ And then specify the minifier command in `_config.yml`:
|
|
244
247
|
minibundle:
|
245
248
|
minifier_commands:
|
246
249
|
css: _bin/remove_whitespace
|
247
|
-
js: node_modules/.bin/uglifyjs
|
250
|
+
js: node_modules/.bin/uglifyjs
|
248
251
|
```
|
249
252
|
|
250
253
|
#### `minibundle` call syntax
|
251
254
|
|
252
255
|
Use `css` or `js` as the argument to the opening tag, for example `{% minibundle css %}`.
|
253
256
|
|
254
|
-
The block contents must be in [YAML]
|
257
|
+
The block contents must be in [YAML] syntax. The supported keys are:
|
255
258
|
|
256
259
|
| Key | Value type | Value example | Default value | Description |
|
257
260
|
| --- | --- | --- | --- | --- |
|
258
|
-
| `source_dir` | string | - | `'_assets'` | The source directory of `assets`, relative to the site directory. |
|
261
|
+
| `source_dir` | string | - | `'_assets'` | The source directory of `assets`, relative to the site directory. You can use period (`.`) to select the site directory itself. |
|
262
|
+
| `assets` | array of strings | `['deps/one', 'deps/two', 'app']` | `[]` | Array of assets relative to `source_dir` directory, without type extension. These are the asset files to be bundled, in order, into one bundle destination file. |
|
259
263
|
| `destination_path` | string | - | `'assets/site'` | The destination path of the bundle file, without type extension, relative to Jekyll's site destination directory. If the value begins with `/` and `baseurl` is empty, `baseurl` will be set to `'/'` implicitly. |
|
260
|
-
| `baseurl` | string | `{{ site.baseurl }}
|
264
|
+
| `baseurl` | string | `'{{ site.baseurl }}/'` | `''` | If nonempty, the bundle destination URL inside `minibundle`'s rendered HTML element will be this value prepended to the destination path of the bundle file. Ignored if `destination_baseurl` is nonempty. |
|
261
265
|
| `destination_baseurl` | string | `'{{ site.cdn_baseurl }}/'` | `''` | If nonempty, the bundle destination URL inside `minibundle`'s rendered HTML element will be this value prepended to the basename of the bundle destination path. See [Separating asset destination path from generated URL](#separating-asset-destination-path-from-generated-url) for more. |
|
262
|
-
| `assets` | array of strings | `['dependency', 'app']` | `[]` | Array of the basenames of assets in `source_dir` directory, without type extension. These are the asset files to be bundled, in order, into one bundle destination file. |
|
263
266
|
| `attributes` | map of keys to string values | `{id: my-link, media: screen}` | `{}` | Custom HTML element attributes to be added to `minibundle`'s rendered HTML element. |
|
267
|
+
| `minifier_cmd` | string | `'node_modules/.bin/uglifyjs'` | - | Minifier command specific to this bundle. See [Minifier command specification](#minifier-command-specification) for more. |
|
264
268
|
|
265
269
|
### Minifier command specification
|
266
270
|
|
@@ -272,14 +276,14 @@ You can specify minifier commands in three places:
|
|
272
276
|
minibundle:
|
273
277
|
minifier_commands:
|
274
278
|
css: _bin/remove_whitespace
|
275
|
-
js: node_modules/.bin/uglifyjs
|
279
|
+
js: node_modules/.bin/uglifyjs
|
276
280
|
```
|
277
281
|
|
278
282
|
2. as environment variables:
|
279
283
|
|
280
284
|
``` bash
|
281
285
|
export JEKYLL_MINIBUNDLE_CMD_CSS=_bin/remove_whitespace
|
282
|
-
export JEKYLL_MINIBUNDLE_CMD_JS="node_modules/.bin/uglifyjs
|
286
|
+
export JEKYLL_MINIBUNDLE_CMD_JS="node_modules/.bin/uglifyjs"
|
283
287
|
```
|
284
288
|
|
285
289
|
3. inside the `minibundle` block with `minifier_cmd` option, allowing
|
@@ -289,7 +293,7 @@ You can specify minifier commands in three places:
|
|
289
293
|
{% minibundle js %}
|
290
294
|
source_dir: _assets/scripts
|
291
295
|
destination_path: assets/site
|
292
|
-
minifier_cmd: node_modules/.bin/uglifyjs
|
296
|
+
minifier_cmd: node_modules/.bin/uglifyjs
|
293
297
|
assets:
|
294
298
|
- dependency
|
295
299
|
- app
|
@@ -385,10 +389,10 @@ Should both be defined, the setting from the environment variable wins.
|
|
385
389
|
### Variable templating
|
386
390
|
|
387
391
|
The template engine used by `ministamp` tag's Hash argument has syntax
|
388
|
-
resembling the ones of [Liquid]
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
+
resembling the ones of [Liquid] and [Mustache], with `{{` and `}}` tags
|
393
|
+
surrounding the variable to be substituted into the output string. For
|
394
|
+
example, given Liquid variable `var = 'foo'`, the template `begin{{ var
|
395
|
+
}}end` results in `beginfooend`.
|
392
396
|
|
393
397
|
The engine supports variable substitution only. It does not support
|
394
398
|
other expressions. If you need to, you can write complex expressions in
|
@@ -489,20 +493,21 @@ The plugin does not work with Jekyll's incremental rebuild feature
|
|
489
493
|
|
490
494
|
## License
|
491
495
|
|
492
|
-
MIT. See
|
496
|
+
MIT. See [LICENSE.txt].
|
493
497
|
|
494
|
-
[
|
495
|
-
[GoogleWebFundamentalsHttpCaching]: https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching#
|
498
|
+
[Gemfile]: https://bundler.io/gemfile.html
|
499
|
+
[GoogleWebFundamentalsHttpCaching]: https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching#invalidating_and_updating_cached_responses
|
496
500
|
[JekyllConf]: https://jekyllrb.com/docs/configuration/
|
497
501
|
[JekyllMinibundleExampleSite]: https://github.com/tkareine/jekyll-minibundle-example
|
498
502
|
[Jekyll]: https://jekyllrb.com/
|
499
|
-
[
|
503
|
+
[LICENSE.txt]: https://raw.githubusercontent.com/tkareine/jekyll-minibundle/master/LICENSE.txt
|
500
504
|
[LiquidAssignTag]: https://shopify.github.io/liquid/tags/variable/#assign
|
501
505
|
[LiquidCaptureBlock]: https://shopify.github.io/liquid/tags/variable/#capture
|
506
|
+
[Liquid]: https://shopify.github.io/liquid/
|
502
507
|
[MD5]: https://en.wikipedia.org/wiki/MD5
|
503
|
-
[
|
508
|
+
[MinibundleCI]: https://github.com/tkareine/jekyll-minibundle/actions?workflow=CI
|
504
509
|
[MinibundleGem]: https://rubygems.org/gems/jekyll-minibundle
|
505
510
|
[Mustache]: https://mustache.github.io/
|
506
|
-
[Sass]:
|
511
|
+
[Sass]: https://sass-lang.com/
|
507
512
|
[UglifyJS2]: https://github.com/mishoo/UglifyJS2
|
508
|
-
[YAML]:
|
513
|
+
[YAML]: https://yaml.org/
|