jekyll-minibundle 2.1.2 → 2.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 +4 -4
- data/CHANGELOG.md +96 -42
- data/LICENSE.txt +1 -1
- data/README.md +232 -52
- data/Rakefile +16 -0
- data/jekyll-minibundle.gemspec +7 -6
- data/lib/jekyll/minibundle/asset_bundle.rb +3 -3
- data/lib/jekyll/minibundle/asset_file_drop.rb +45 -0
- data/lib/jekyll/minibundle/asset_file_properties.rb +12 -8
- data/lib/jekyll/minibundle/asset_file_registry.rb +4 -4
- data/lib/jekyll/minibundle/asset_tag_markup.rb +21 -20
- data/lib/jekyll/minibundle/bundle_file.rb +6 -1
- data/lib/jekyll/minibundle/development_file.rb +2 -1
- data/lib/jekyll/minibundle/development_file_collection.rb +2 -2
- data/lib/jekyll/minibundle/environment.rb +13 -15
- data/lib/jekyll/minibundle/files.rb +16 -18
- data/lib/jekyll/minibundle/hashes.rb +10 -12
- data/lib/jekyll/minibundle/log.rb +5 -7
- data/lib/jekyll/minibundle/mini_bundle_block.rb +35 -12
- data/lib/jekyll/minibundle/mini_stamp_tag.rb +108 -16
- data/lib/jekyll/minibundle/stamp_file.rb +1 -0
- data/lib/jekyll/minibundle/variable_template.rb +145 -0
- data/lib/jekyll/minibundle/variable_template_registry.rb +19 -0
- data/lib/jekyll/minibundle/version.rb +1 -1
- data/test/fixture/site/_bin/with_count +1 -1
- data/test/integration/minibundle_development_mode_test.rb +146 -61
- data/test/integration/minibundle_production_mode_test.rb +271 -143
- data/test/integration/ministamp_development_mode_test.rb +66 -25
- data/test/integration/ministamp_production_mode_test.rb +129 -37
- data/test/integration/static_files_as_asset_sources_test.rb +10 -10
- data/test/support/assertions.rb +1 -1
- data/test/support/{static_file_api_config.rb → static_file_config.rb} +6 -3
- data/test/support/test_case.rb +7 -4
- data/test/unit/asset_bundle_test.rb +6 -6
- data/test/unit/asset_file_drop_test.rb +65 -0
- data/test/unit/asset_file_registry_test.rb +136 -98
- data/test/unit/asset_tag_markup_test.rb +11 -5
- data/test/unit/bundle_file_properties_test.rb +44 -23
- data/test/unit/bundle_file_writing_test.rb +50 -32
- data/test/unit/development_file_properties_test.rb +95 -0
- data/test/unit/development_file_writing_test.rb +15 -6
- data/test/unit/environment_test.rb +3 -3
- data/test/unit/files_test.rb +7 -7
- data/test/unit/hashes_test.rb +12 -12
- data/test/unit/jekyll_static_file_api_test.rb +91 -20
- data/test/unit/mini_bundle_block_test.rb +59 -9
- data/test/unit/mini_stamp_tag_test.rb +37 -6
- data/test/unit/stamp_file_properties_test.rb +47 -24
- data/test/unit/stamp_file_writing_test.rb +33 -24
- data/test/unit/variable_template_test.rb +121 -0
- metadata +27 -6
- data/test/unit/development_file_collection_properties_test.rb +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 774c41fc9b64c1637821907e5cbd27b1cc57fb3c
|
4
|
+
data.tar.gz: 507bd31ab11d4c7b3c7944116af11ff63fd27f0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95c4db067065b679412388f72629cf3eafa12cf99c1d6bad244715b2917fca09f41e13f97e6d3ee28d7fc2df191a7532576fe999327cc2c2f7e6100ea6488ff8
|
7
|
+
data.tar.gz: 26b81832194d0e5d86dc1d99ecdb6de65e463c8ef228190b7b84e98dfdf63ae908e4be5f59bd1ba1a4bdb488ada439cf9b29079604d5e08776819aa21f4985bd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
# 2.2.0 / 2017-03-10
|
2
|
+
|
3
|
+
* Treat `ministamp` tag's argument as YAML, resulting either in String
|
4
|
+
or Hash type of argument after YAML parsing. If argument is of Hash
|
5
|
+
type, render values with Liquid-like templating support, allowing
|
6
|
+
rendering Liquid variables. This change is backwards compatible.
|
7
|
+
|
8
|
+
* Add support for separating asset destination path from the generated
|
9
|
+
asset URL. See `render_basename_only` option of `ministamp` tag and
|
10
|
+
`destination_baseurl` option of `minibundle` block.
|
11
|
+
|
12
|
+
* Escape the URLs generated by `ministamp` tag and `minibundle` block.
|
13
|
+
|
14
|
+
* Quote paths in error messages more consistently.
|
15
|
+
|
16
|
+
* Show better error messages in various situations when asset source
|
17
|
+
file does not exist.
|
18
|
+
|
19
|
+
* Compatibility: conform to Jekyll 3.4.2's StaticFile public API.
|
20
|
+
|
1
21
|
# 2.1.2 / 2017-02-28
|
2
22
|
|
3
23
|
* Bug fix: remove unnecessary '.' path component from asset destination
|
@@ -23,31 +43,36 @@
|
|
23
43
|
```
|
24
44
|
|
25
45
|
* Bug fix (related to above): don't let Jekyll's watch mode
|
26
|
-
(auto-
|
46
|
+
(auto-regeneration) remove asset from generated site directory when
|
27
47
|
asset destination path has no subdirectory.
|
28
|
-
|
48
|
+
|
49
|
+
* Show bundle destination path in bundling log message.
|
29
50
|
|
30
51
|
# 2.1.1 / 2017-01-14
|
31
52
|
|
32
53
|
* Fix the file permissions of `minibundle` block's output file to
|
33
54
|
respect umask setting. Bug report from Alfonse Surigao.
|
34
|
-
|
55
|
+
|
56
|
+
* Compatibility: conform to Jekyll 3.3's StaticFile public API.
|
35
57
|
|
36
58
|
# 2.1.0 / 2016-05-04
|
37
59
|
|
38
60
|
* Allow attributes without values. Useful for `async` attribute, for
|
39
61
|
example. Pull Request #7 by Sam (@codewisdom).
|
40
|
-
|
62
|
+
|
63
|
+
* Ensure attribute value conversion to string.
|
41
64
|
|
42
65
|
# 2.0.1 / 2016-04-06
|
43
66
|
|
44
|
-
* Fix Jekyll version requirement check to be more reliable
|
67
|
+
* Fix Jekyll version requirement check to be more reliable.
|
45
68
|
|
46
69
|
# 2.0.0 / 2016-04-01
|
47
70
|
|
48
|
-
* Drop support for Jekyll versions below 3
|
71
|
+
* Drop support for Jekyll versions below 3.
|
72
|
+
|
49
73
|
* Remove unused asset cache entries and temporary files when Jekyll
|
50
|
-
rebuilds the site
|
74
|
+
rebuilds the site.
|
75
|
+
|
51
76
|
* Document a known caveat: the plugin doesn't work with Jekyll's
|
52
77
|
incremental rebuild feature.
|
53
78
|
|
@@ -55,26 +80,33 @@
|
|
55
80
|
|
56
81
|
* Log the last 2000 bytes of minifier's STDOUT output if the minifier
|
57
82
|
command fails. Pull Request #6 by Martin Nordholts (@Enselic).
|
83
|
+
|
58
84
|
* Allow prepending base URL for the destination path of `minibundle`
|
59
|
-
block
|
60
|
-
|
85
|
+
block.
|
86
|
+
|
87
|
+
* Drop Ruby MRI 1.9 support because Jekyll 3 does not support it.
|
88
|
+
|
61
89
|
* Fix issues in asset reloading in Jekyll's watch (auto-regeneration)
|
62
|
-
mode, doing bundling and asset fingerprinting again
|
90
|
+
mode, doing bundling and asset fingerprinting again.
|
63
91
|
|
64
92
|
# 1.5.1 / 2015-01-29
|
65
93
|
|
66
94
|
* Improve future compatibility with Jekyll. Minibundle has classes
|
67
95
|
adhering to `Jekyll::StaticFile` interface, and some method
|
68
96
|
implementations of the interface were missing.
|
69
|
-
|
97
|
+
|
98
|
+
* Small refactorings and test improvements.
|
70
99
|
|
71
100
|
# 1.5.0 / 2014-07-27
|
72
101
|
|
73
102
|
* Support minifier command specification in `_config.yml` and inside
|
74
103
|
`minibundle` block. Issue #4 by Phillip Smith (@phillipadsmith).
|
75
|
-
|
76
|
-
*
|
77
|
-
|
104
|
+
|
105
|
+
* Support enabling development mode from `_config.yml`.
|
106
|
+
|
107
|
+
* Add argument validation to `minibundle` block and `ministamp` tag.
|
108
|
+
|
109
|
+
* Document how to load the gem with Jekyll's `gems` config setting.
|
78
110
|
|
79
111
|
# 1.4.6 / 2014-05-10
|
80
112
|
|
@@ -84,14 +116,17 @@
|
|
84
116
|
# 1.4.5 / 2014-05-10
|
85
117
|
|
86
118
|
* Use SafeYAML to load user input from `minibundle` block for
|
87
|
-
consistent behavior with Jekyll and for security
|
88
|
-
|
119
|
+
consistent behavior with Jekyll and for security.
|
120
|
+
|
121
|
+
* Clean log messages: show relative paths when bundling assets.
|
122
|
+
|
89
123
|
* Add missing implementations of `relative_path` and `to_liquid`
|
90
124
|
methods from Jekyll's StaticFile API (introduced in Jekyll v1.5.0),
|
91
125
|
allowing Minibundle to behave better with other Jekyll
|
92
126
|
plugins. Issue #3 by Michael Rose (@mmistakes).
|
127
|
+
|
93
128
|
* Fix Ruby deprecation warnings (use `File.exist?` instead of
|
94
|
-
`File.exists?`)
|
129
|
+
`File.exists?`).
|
95
130
|
|
96
131
|
# 1.4.4 / 2014-01-16
|
97
132
|
|
@@ -102,12 +137,17 @@
|
|
102
137
|
|
103
138
|
# 1.4.3 / 2014-01-16
|
104
139
|
|
105
|
-
* Do not leak read pipe file descriptor upon minifier command failure
|
106
|
-
|
107
|
-
*
|
108
|
-
|
109
|
-
*
|
110
|
-
|
140
|
+
* Do not leak read pipe file descriptor upon minifier command failure.
|
141
|
+
|
142
|
+
* Loosen version constraints for development gem dependencies.
|
143
|
+
|
144
|
+
* Clarify documentation.
|
145
|
+
|
146
|
+
* Fix some Ruby coding style issues.
|
147
|
+
|
148
|
+
* Minor internal state handling improvements.
|
149
|
+
|
150
|
+
* Clarify tests, increase test coverage.
|
111
151
|
|
112
152
|
# 1.4.2 / 2013-12-28
|
113
153
|
|
@@ -115,13 +155,15 @@
|
|
115
155
|
unintentional edge case earlier. Now the behavior of touching the
|
116
156
|
asset source is consistent with when changing the contents of the
|
117
157
|
source.
|
158
|
+
|
118
159
|
* Separate tags produced by `minibundle` in development mode with
|
119
|
-
newlines
|
120
|
-
|
160
|
+
newlines.
|
161
|
+
|
162
|
+
* Clarify tests, increase coverage.
|
121
163
|
|
122
164
|
# 1.4.1 / 2013-12-27
|
123
165
|
|
124
|
-
* Add missing files to gem package
|
166
|
+
* Add missing files to gem package.
|
125
167
|
|
126
168
|
# 1.4.0 / 2013-12-27
|
127
169
|
|
@@ -137,37 +179,49 @@
|
|
137
179
|
in Jekyll. Otherwise, we would potentially get to inconsistencies in
|
138
180
|
Jekyll's watch mode. See "Jekyll static file restriction" in
|
139
181
|
README.md. Issue #2 by Austin Grigg (@agrigg).
|
140
|
-
|
182
|
+
|
183
|
+
* Upgrade development dependencies.
|
141
184
|
|
142
185
|
# 1.2.0 / 2013-09-29
|
143
186
|
|
144
|
-
* If Jekyll's logger is available, use it for nice output when bundling
|
145
|
-
|
146
|
-
*
|
187
|
+
* If Jekyll's logger is available, use it for nice output when bundling.
|
188
|
+
|
189
|
+
* Upgrade development dependencies.
|
190
|
+
|
191
|
+
* Simplify `BundleFile` class implementation.
|
147
192
|
|
148
193
|
# 1.1.0 / 2013-02-27
|
149
194
|
|
150
|
-
* `ministamp` tag omits fingerprint in development mode
|
151
|
-
|
195
|
+
* `ministamp` tag omits fingerprint in development mode.
|
196
|
+
|
197
|
+
* Clarify documentation.
|
198
|
+
|
152
199
|
* Comply with (Gemnasium) conventions for changelogs. Pull Request #1
|
153
200
|
by Teemu Matilainen (@tmatilai).
|
154
|
-
|
155
|
-
* Bug fix: do not bundle assets
|
201
|
+
|
202
|
+
* Bug fix: do not bundle assets when nonrelated files change.
|
203
|
+
|
204
|
+
* Bug fix: do not bundle assets twice upon startup.
|
156
205
|
|
157
206
|
# 1.0.0 / 2013-02-15
|
158
207
|
|
159
208
|
* Add development mode, where `minibundle` block will copy each asset
|
160
|
-
as-is to the destination directory
|
161
|
-
|
162
|
-
*
|
209
|
+
as-is to the destination directory.
|
210
|
+
|
211
|
+
* Clarify documentation.
|
212
|
+
|
213
|
+
* Increase test coverage.
|
163
214
|
|
164
215
|
# 0.2.0 / 2012-12-15
|
165
216
|
|
166
|
-
* Escape the values of custom attributes given in `minibundle` block
|
167
|
-
|
168
|
-
*
|
217
|
+
* Escape the values of custom attributes given in `minibundle` block.
|
218
|
+
|
219
|
+
* Add semicolons between each JavaScript asset in bundling.
|
220
|
+
|
221
|
+
* Show error in page output if asset bundling command failed.
|
169
222
|
|
170
223
|
# 0.1.0 / 2012-12-07
|
171
224
|
|
172
|
-
* Add `ministamp` tag and `minibundle` block for Jekyll
|
173
|
-
|
225
|
+
* Add `ministamp` tag and `minibundle` block for Jekyll.
|
226
|
+
|
227
|
+
* First release.
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -60,7 +60,7 @@ Then, instruct Jekyll to load the gem by adding this line to the
|
|
60
60
|
gems: ['jekyll/minibundle']
|
61
61
|
```
|
62
62
|
|
63
|
-
An alternative to using the `gems` configuration
|
63
|
+
An alternative to using the `gems` configuration option is to add
|
64
64
|
`_plugins/minibundle.rb` file to your site project with this line:
|
65
65
|
|
66
66
|
``` ruby
|
@@ -68,38 +68,94 @@ require 'jekyll/minibundle'
|
|
68
68
|
```
|
69
69
|
|
70
70
|
You must allow Jekyll to use custom plugins. That is, do not enable
|
71
|
-
Jekyll's `safe`
|
71
|
+
Jekyll's `safe` option.
|
72
72
|
|
73
73
|
### Asset fingerprinting
|
74
74
|
|
75
75
|
If you just want to have an MD5 fingerprint in your asset's path, use
|
76
|
-
`ministamp` [Liquid][Liquid] tag. For example:
|
76
|
+
`ministamp` [Liquid][Liquid] tag in a Liquid template file. For example:
|
77
77
|
|
78
|
-
```
|
79
|
-
<link href="{{ site.baseurl }}{% ministamp _assets/site.css assets/site.css %}"
|
78
|
+
``` liquid
|
79
|
+
<link rel="stylesheet" href="{{ site.baseurl }}/{% ministamp _assets/site.css assets/site.css %}" media="screen, projection">
|
80
80
|
```
|
81
81
|
|
82
82
|
When it's time to render the `ministamp` tag, the plugin copies the
|
83
83
|
source file (`_assets/site.css`, the first tag argument) to the
|
84
84
|
specified destination path (`assets/site.css`, the second tag argument)
|
85
|
-
in Jekyll's
|
85
|
+
in Jekyll's site destination directory. The filename will contain a
|
86
|
+
fingerprint.
|
86
87
|
|
87
|
-
|
88
|
+
The tag outputs the asset destination path, encoded for HTML, into
|
89
|
+
Liquid's template rendering outcome. For example, when `site.baseurl` is
|
90
|
+
empty:
|
88
91
|
|
89
92
|
``` html
|
90
|
-
<link href="/assets/site-390be921ee0eff063817bb5ef2954300.css"
|
93
|
+
<link rel="stylesheet" href="/assets/site-390be921ee0eff063817bb5ef2954300.css" media="screen, projection">
|
91
94
|
```
|
92
95
|
|
93
96
|
This feature is useful when combined with asset generation tools
|
94
97
|
external to Jekyll. For example, you can configure [Sass][Sass] to take
|
95
98
|
input files from `_assets/styles/*.scss` and to produce output to
|
96
99
|
`_tmp/site.css`. Then, you use `ministamp` tag to copy the file with a
|
97
|
-
fingerprint to Jekyll's
|
100
|
+
fingerprint to Jekyll's site destination directory:
|
98
101
|
|
99
|
-
```
|
100
|
-
<link href="{{ site.baseurl }}{% ministamp _tmp/site.css assets/site.css %}"
|
102
|
+
``` liquid
|
103
|
+
<link rel="stylesheet" href="{{ site.baseurl }}/{% ministamp _tmp/site.css assets/site.css %}">
|
104
|
+
```
|
105
|
+
|
106
|
+
#### `ministamp` call syntax
|
107
|
+
|
108
|
+
The argument for `ministamp` tag must be in [YAML][YAML] syntax, and
|
109
|
+
parsing the argument as YAML must result either in a String or a
|
110
|
+
Hash. What you saw previously was the argument being parsed as a String;
|
111
|
+
it's effectively a shorthand version of passing the argument as a Hash
|
112
|
+
with certain keys. That is, in the following call:
|
113
|
+
|
114
|
+
``` liquid
|
115
|
+
{% ministamp _tmp/site.css assets/site.css %}
|
116
|
+
```
|
117
|
+
|
118
|
+
the argument is a String: `"_tmp/site.css assets/site.css"`. The call is
|
119
|
+
equivalent to the following call with Hash argument:
|
120
|
+
|
121
|
+
``` liquid
|
122
|
+
{% ministamp { source_path: _tmp/site.css, destination_path: assets/site.css } %}
|
101
123
|
```
|
102
124
|
|
125
|
+
The Hash argument allows expressing more options and quoting
|
126
|
+
`source_path` and `destination_path` values, if needed.
|
127
|
+
|
128
|
+
The supported keys for the Hash argument are:
|
129
|
+
|
130
|
+
| Key | Required? | Value type | Value example | Default value | Description |
|
131
|
+
| --- | --- | --- | --- | --- | --- |
|
132
|
+
| `source_path` | yes | string | `'_tmp/site.css'` | - | The source path of the asset file, relative to the site directory. |
|
133
|
+
| `destination_path` | yes | string | `'assets/site.css'` | - | The destination path of the asset file, relative to Jekyll's site destination directory. If the value begins with `/` and `render_basename_only` is `false`, `ministamp`'s output will begin with `/`. |
|
134
|
+
| `render_basename_only` | no | boolean | `true` | `false` | If `true`, `ministamp`'s rendered URL will be the basename of the asset destination path. See [Separating asset destination path from generated URL](#separating-asset-destination-path-from-generated-url) for more. |
|
135
|
+
|
136
|
+
With Hash argument, the plugin processes `source_path` and
|
137
|
+
`destination_path` values through a tiny template engine. This allows
|
138
|
+
you to use Liquid's variables as input to `ministamp` tag. An example
|
139
|
+
with Liquid's [`assign`][LiquidAssignTag] tag:
|
140
|
+
|
141
|
+
``` liquid
|
142
|
+
{% assign asset_dir = 'assets' %}
|
143
|
+
<link rel="stylesheet" href="{% ministamp { source_path: _tmp/site.css, destination_path: '{{ asset_dir }}/site.css' } %}">
|
144
|
+
```
|
145
|
+
|
146
|
+
The above would use `assets/site.css` as the destination path.
|
147
|
+
|
148
|
+
Note that you must quote `destination_path`'s value, otherwise YAML does
|
149
|
+
not recognize it as a proper string.
|
150
|
+
|
151
|
+
To refer to Jekyll's configuration options ([`_config.yml`][JekyllConf])
|
152
|
+
in the template, prefix the variable name with `site.`. For example, to
|
153
|
+
refer to `baseurl` option, use syntax `{{ site.baseurl }}` in the
|
154
|
+
template.
|
155
|
+
|
156
|
+
See [Variable templating](#variable-templating) for details about the
|
157
|
+
template syntax.
|
158
|
+
|
103
159
|
### Asset bundling
|
104
160
|
|
105
161
|
This is a straightforward way to bundle assets with any minification
|
@@ -107,19 +163,19 @@ tool that supports reading input from STDIN and writing the output to
|
|
107
163
|
STDOUT. You write the configuration for input sources directly into the
|
108
164
|
content file where you want the markup tag for the bundle file to
|
109
165
|
appear. The markup tag contains the path to the bundle file, and the
|
110
|
-
Jekyll's
|
111
|
-
path will contain an MD5 fingerprint.
|
166
|
+
Jekyll's site destination directory will have the bundle file at that
|
167
|
+
path. The path will contain an MD5 fingerprint.
|
112
168
|
|
113
|
-
Place `minibundle` [Liquid][Liquid] block into
|
114
|
-
you want the generated markup to appear. Write bundling
|
115
|
-
inside the block in [YAML][YAML] syntax. For example, to
|
116
|
-
JavaScript sources:
|
169
|
+
Place `minibundle` [Liquid][Liquid] block into the Liquid template file
|
170
|
+
where you want the block's generated markup to appear. Write bundling
|
171
|
+
configuration inside the block in [YAML][YAML] syntax. For example, to
|
172
|
+
bundle a set of JavaScript sources:
|
117
173
|
|
118
174
|
``` text
|
119
175
|
{% minibundle js %}
|
120
176
|
source_dir: _assets/scripts
|
121
177
|
destination_path: assets/site
|
122
|
-
baseurl: {{ site.baseurl }}
|
178
|
+
baseurl: '{{ site.baseurl }}/'
|
123
179
|
assets:
|
124
180
|
- dependency
|
125
181
|
- app
|
@@ -133,7 +189,7 @@ Then, specify the command for launching your favorite minifier in
|
|
133
189
|
`_config.yml`:
|
134
190
|
|
135
191
|
``` yaml
|
136
|
-
baseurl:
|
192
|
+
baseurl: ''
|
137
193
|
|
138
194
|
minibundle:
|
139
195
|
minifier_commands:
|
@@ -146,10 +202,12 @@ contents of the asset files in `source_dir` directory as input to the
|
|
146
202
|
minifier (STDIN). The feeding order is the order of the files in the
|
147
203
|
`assets` key in the block configuration. The plugin expects the minifier
|
148
204
|
to produce output (STDOUT) and writes it to the file at
|
149
|
-
`destination_path` in Jekyll's
|
150
|
-
contain a fingerprint.
|
205
|
+
`destination_path` in Jekyll's site destination directory. The filename
|
206
|
+
will contain a fingerprint.
|
151
207
|
|
152
|
-
|
208
|
+
The block outputs `<link>` (for `css` type) or `<script>` (for `js`
|
209
|
+
type) HTML element into Liquid's template rendering outcome. Continuing
|
210
|
+
the example above, the block's output will be:
|
153
211
|
|
154
212
|
``` html
|
155
213
|
<script src="/assets/site-8e764372a0dbd296033cb2a416f064b5.js" type="text/javascript" id="my-scripts" async></script>
|
@@ -159,6 +217,11 @@ You can pass custom attributes, like `id="my-scripts"` and `async`
|
|
159
217
|
above, to the generated markup with `attributes` map inside the
|
160
218
|
`minibundle` block.
|
161
219
|
|
220
|
+
As shown above for the `baseurl` key, you can use Liquid template syntax
|
221
|
+
inside the contents of the block. Liquid renders block contents before
|
222
|
+
`minibundle` block gets the turn to render itself. Just ensure that
|
223
|
+
block contents will result in valid YAML.
|
224
|
+
|
162
225
|
For bundling CSS assets, use `css` as the argument to the `minibundle`
|
163
226
|
block:
|
164
227
|
|
@@ -166,7 +229,7 @@ block:
|
|
166
229
|
{% minibundle css %}
|
167
230
|
source_dir: _assets/styles
|
168
231
|
destination_path: assets/site
|
169
|
-
baseurl: {{ site.baseurl }}
|
232
|
+
baseurl: '{{ site.baseurl }}/'
|
170
233
|
assets:
|
171
234
|
- reset
|
172
235
|
- common
|
@@ -184,6 +247,21 @@ minibundle:
|
|
184
247
|
js: node_modules/.bin/uglifyjs -
|
185
248
|
```
|
186
249
|
|
250
|
+
#### `minibundle` call syntax
|
251
|
+
|
252
|
+
Use `css` or `js` as the argument to the opening tag, for example `{% minibundle css %}`.
|
253
|
+
|
254
|
+
The block contents must be in [YAML][YAML] syntax. The supported keys are:
|
255
|
+
|
256
|
+
| Key | Value type | Value example | Default value | Description |
|
257
|
+
| --- | --- | --- | --- | --- |
|
258
|
+
| `source_dir` | string | - | `'_assets'` | The source directory of `assets`, relative to the site directory. |
|
259
|
+
| `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 }}/` | `''` | 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
|
+
| `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
|
+
| `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. |
|
264
|
+
|
187
265
|
### Minifier command specification
|
188
266
|
|
189
267
|
You can specify minifier commands in three places:
|
@@ -204,7 +282,7 @@ You can specify minifier commands in three places:
|
|
204
282
|
export JEKYLL_MINIBUNDLE_CMD_JS="node_modules/.bin/uglifyjs -"
|
205
283
|
```
|
206
284
|
|
207
|
-
3. inside the minibundle block with `minifier_cmd`
|
285
|
+
3. inside the `minibundle` block with `minifier_cmd` option, allowing
|
208
286
|
blocks to have different commands from each other:
|
209
287
|
|
210
288
|
``` text
|
@@ -222,31 +300,33 @@ You can specify minifier commands in three places:
|
|
222
300
|
|
223
301
|
These ways of specification are listed in increasing order of
|
224
302
|
specificity. Should multiple commands apply to a block, the most
|
225
|
-
specific one wins. For example, the `minifier_cmd`
|
226
|
-
|
303
|
+
specific one wins. For example, the `minifier_cmd` option inside `{%
|
304
|
+
minibundle js }%` block overrides the setting in
|
227
305
|
`$JEKYLL_MINIBUNDLE_CMD_JS` environment variable.
|
228
306
|
|
229
307
|
### Recommended directory layout
|
230
308
|
|
231
309
|
It's recommended that you exclude the files you use as asset sources
|
232
310
|
from Jekyll itself. Otherwise, you end up with duplicate files in the
|
233
|
-
|
311
|
+
site destination directory.
|
234
312
|
|
235
313
|
For example, in the following snippet we're using `assets/src.css` as
|
236
314
|
asset source to `ministamp` tag:
|
237
315
|
|
238
|
-
```
|
239
|
-
<!-- BAD: unless assets dir is excluded, both src.css and dest.css will be copied to
|
240
|
-
<link href="{{ site.baseurl }}{% ministamp assets/src.css assets/dest.css %}"
|
316
|
+
``` liquid
|
317
|
+
<!-- BAD: unless assets dir is excluded, both src.css and dest.css will be copied to site destination directory -->
|
318
|
+
<link rel="stylesheet" href="{{ site.baseurl }}/{% ministamp assets/src.css assets/dest.css %}" media="screen, projection">
|
241
319
|
```
|
242
320
|
|
243
|
-
By default, Jekyll includes this file to the
|
244
|
-
result, there will be both `src.css` and
|
245
|
-
`_site/assets/` directory, which you probably
|
321
|
+
By default, Jekyll includes this file to the site destination
|
322
|
+
directory. As a result, there will be both `src.css` and
|
323
|
+
`dest-<md5>.css` files in `_site/assets/` directory, which you probably
|
324
|
+
do not want.
|
246
325
|
|
247
|
-
In order to avoid this, exclude the asset source file from
|
248
|
-
|
249
|
-
|
326
|
+
In order to avoid this, exclude the asset source file from Jekyll.
|
327
|
+
Because Jekyll's site generation excludes underscore directories (that
|
328
|
+
is, directories whose name begins with underscore character), consider
|
329
|
+
using the following directory layout:
|
250
330
|
|
251
331
|
* `_assets/` for JavaScript and CSS assets handled by the plugin that
|
252
332
|
are in version control
|
@@ -254,6 +334,27 @@ character (`_`), consider using the following directory layout:
|
|
254
334
|
that are not in version control (for example, Sass output files)
|
255
335
|
* `assets/` for images and other assets handled by Jekyll directly
|
256
336
|
|
337
|
+
However, Jekyll's watch mode (auto-regeneration) does monitor files
|
338
|
+
inside underscore directories. If such a file is modified, the watch
|
339
|
+
mode triggers site generation. For Minibundle's functionality, this is
|
340
|
+
beneficial: it allows the plugin to check if assets need to be updated
|
341
|
+
to the site destination directory.
|
342
|
+
|
343
|
+
The `exclude` [Jekyll configuration][JekyllConf] option affects Jekyll's
|
344
|
+
watch mode. Given the recommended directory layout above, if you set the
|
345
|
+
following in `_config.yml`:
|
346
|
+
|
347
|
+
``` yaml
|
348
|
+
exclude:
|
349
|
+
- _assets
|
350
|
+
- _tmp
|
351
|
+
```
|
352
|
+
|
353
|
+
Then Jekyll won't see if files inside those directories have changed and
|
354
|
+
the plugin won't get the chance to update assets to the site destination
|
355
|
+
directory. So, don't explicitly exclude `_assets` and `_tmp`
|
356
|
+
directories.
|
357
|
+
|
257
358
|
See [Jekyll configuration][JekyllConf] for more about excluding files
|
258
359
|
and directories.
|
259
360
|
|
@@ -261,9 +362,11 @@ and directories.
|
|
261
362
|
|
262
363
|
If you set `$JEKYLL_MINIBUNDLE_MODE` environment variable to
|
263
364
|
`development`, then the plugin will copy asset files as is to Jekyll's
|
264
|
-
|
265
|
-
|
266
|
-
|
365
|
+
site destination directory and omit fingerprinting.
|
366
|
+
|
367
|
+
The development mode changes `minibundle` block's `destination_path`
|
368
|
+
option to be the base directory for files mentioned in `assets`
|
369
|
+
option. This is useful in development workflow, where you need the
|
267
370
|
filenames and line numbers of the original asset sources.
|
268
371
|
|
269
372
|
``` bash
|
@@ -279,22 +382,100 @@ minibundle:
|
|
279
382
|
|
280
383
|
Should both be defined, the setting from the environment variable wins.
|
281
384
|
|
385
|
+
### Variable templating
|
386
|
+
|
387
|
+
The template engine used by `ministamp` tag's Hash argument has syntax
|
388
|
+
resembling the ones of [Liquid][Liquid] and [Mustache][Mustache], with
|
389
|
+
`{{` and `}}` tags surrounding the variable to be substituted into the
|
390
|
+
output string. For example, given Liquid variable `var = 'foo'`, the
|
391
|
+
template `begin{{ var }}end` results in `beginfooend`.
|
392
|
+
|
393
|
+
The engine supports variable substitution only. It does not support
|
394
|
+
other expressions. If you need to, you can write complex expressions in
|
395
|
+
Liquid, store the result to a variable, and use the variable in the
|
396
|
+
template.
|
397
|
+
|
398
|
+
If you need literal `{` or `}` characters in the template, you can
|
399
|
+
escape them with backslash. For example, `\{` results in `{` in the
|
400
|
+
output. To output backslash character itself, write it twice: `\\`
|
401
|
+
results in `\` in the output.
|
402
|
+
|
403
|
+
Inside variable subsitution (between `{{` and `}}`), anything before the
|
404
|
+
closing `}}` tag is interpreted as part of the variable name, except
|
405
|
+
that the engine removes any leading and trailing whitespace from the
|
406
|
+
name. For example, in the template `{{ var } }}`, `var }` is treated as
|
407
|
+
the name of the variable.
|
408
|
+
|
409
|
+
A reference to undefined variable results in empty string. For example,
|
410
|
+
`begin{{ nosuch }}end` will output `beginend` if there's no variable
|
411
|
+
named `nosuch`.
|
412
|
+
|
413
|
+
### Separating asset destination path from generated URL
|
414
|
+
|
415
|
+
Use `render_basename_only: true` option of `ministamp` tag and
|
416
|
+
`destination_baseurl` option of `minibundle` block to separate the
|
417
|
+
destination path of the asset file from the generated URL of the
|
418
|
+
asset. This allows you to serve the asset from a separate domain, for
|
419
|
+
example.
|
420
|
+
|
421
|
+
Example usage, with the following content in `_config.yml`:
|
422
|
+
|
423
|
+
``` yaml
|
424
|
+
cdn_baseurl: 'https://cdn.example.com'
|
425
|
+
```
|
426
|
+
|
427
|
+
For `ministamp` tag:
|
428
|
+
|
429
|
+
``` liquid
|
430
|
+
<link rel="stylesheet" href="{{ site.cdn_baseurl }}/css/{% ministamp { source_path: '_tmp/site.css', destination_path: assets/site.css, render_basename_only: true } %}">
|
431
|
+
```
|
432
|
+
|
433
|
+
The asset file will be in Jekyll's site destination directory with path
|
434
|
+
`assets/site-ff9c63f843b11f9c3666fe46caaddea8.css`, and Liquid's
|
435
|
+
rendering will result in:
|
436
|
+
|
437
|
+
``` html
|
438
|
+
<link rel="stylesheet" href="https://cdn.example.com/css/site-ff9c63f843b11f9c3666fe46caaddea8.css">
|
439
|
+
```
|
440
|
+
|
441
|
+
For `minibundle` block:
|
442
|
+
|
443
|
+
``` liquid
|
444
|
+
{% minibundle js %}
|
445
|
+
source_dir: _assets/scripts
|
446
|
+
destination_path: assets/site
|
447
|
+
destination_baseurl: '{{ site.cdn_baseurl }}/js/'
|
448
|
+
assets:
|
449
|
+
- dependency
|
450
|
+
- app
|
451
|
+
{% endminibundle %}
|
452
|
+
```
|
453
|
+
|
454
|
+
The bundle file will be in Jekyll's site destination directory with path
|
455
|
+
`assets/site-4782a1f67803038d4f8351051e67deb8.js`, and Liquid's
|
456
|
+
rendering will result in:
|
457
|
+
|
458
|
+
``` html
|
459
|
+
<script type="text/javascript" src="https://cdn.example.com/js/site-4782a1f67803038d4f8351051e67deb8.js"></script>
|
460
|
+
```
|
461
|
+
|
282
462
|
### Capturing Liquid output
|
283
463
|
|
284
|
-
Use Liquid's `capture` block to store output
|
285
|
-
to a variable, as a string. Then you can
|
464
|
+
Use Liquid's [`capture`][LiquidCaptureBlock] block to store output
|
465
|
+
rendered inside the block to a variable, as a string. Then you can
|
466
|
+
process the string as you like.
|
286
467
|
|
287
468
|
For example:
|
288
469
|
|
289
|
-
```
|
290
|
-
{% capture
|
291
|
-
<link href="{{
|
470
|
+
``` liquid
|
471
|
+
{% capture site_css %}{% ministamp _assets/site.css assets/site.css %}{% endcapture %}
|
472
|
+
<link rel="stylesheet" href="{{ site_css | remove_first: "assets/" }}">
|
292
473
|
```
|
293
474
|
|
294
|
-
|
475
|
+
Liquid's rendering outcome:
|
295
476
|
|
296
477
|
``` html
|
297
|
-
<link href="
|
478
|
+
<link rel="stylesheet" href="site-390be921ee0eff063817bb5ef2954300.css">
|
298
479
|
```
|
299
480
|
|
300
481
|
## Example site
|
@@ -303,12 +484,8 @@ See the sources of [an example site][JekyllMinibundleExampleSite].
|
|
303
484
|
|
304
485
|
## Known caveats
|
305
486
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
2. `ministamp` tag does not interpret Liquid variables, as the tag just
|
310
|
-
takes in string literals. Improving this would require new syntax for
|
311
|
-
tag arguments.
|
487
|
+
The plugin does not work with Jekyll's incremental rebuild feature
|
488
|
+
(Jekyll option `--incremental`).
|
312
489
|
|
313
490
|
## License
|
314
491
|
|
@@ -320,9 +497,12 @@ MIT. See `LICENSE.txt`.
|
|
320
497
|
[JekyllMinibundleExampleSite]: https://github.com/tkareine/jekyll-minibundle-example
|
321
498
|
[Jekyll]: https://jekyllrb.com/
|
322
499
|
[Liquid]: https://shopify.github.io/liquid/
|
500
|
+
[LiquidAssignTag]: https://shopify.github.io/liquid/tags/variable/#assign
|
501
|
+
[LiquidCaptureBlock]: https://shopify.github.io/liquid/tags/variable/#capture
|
323
502
|
[MD5]: https://en.wikipedia.org/wiki/MD5
|
324
503
|
[MinibundleBuild]: https://travis-ci.org/tkareine/jekyll-minibundle
|
325
504
|
[MinibundleGem]: https://rubygems.org/gems/jekyll-minibundle
|
505
|
+
[Mustache]: https://mustache.github.io/
|
326
506
|
[Sass]: http://sass-lang.com/
|
327
507
|
[UglifyJS2]: https://github.com/mishoo/UglifyJS2
|
328
508
|
[YAML]: http://www.yaml.org/
|