jekyll-minibundle 1.0.0 → 1.1.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 +15 -0
- data/{History.md → CHANGELOG.md} +11 -3
- data/{License.txt → LICENSE.txt} +0 -0
- data/README.md +157 -0
- data/RELEASING.txt +11 -0
- data/Rakefile +1 -1
- data/jekyll-minibundle.gemspec +70 -0
- data/lib/jekyll/minibundle/asset_bundle.rb +2 -4
- data/lib/jekyll/minibundle/asset_file_paths.rb +2 -2
- data/lib/jekyll/minibundle/bundle_file.rb +36 -20
- data/lib/jekyll/minibundle/development_file.rb +1 -7
- data/lib/jekyll/minibundle/development_file_collection.rb +3 -3
- data/lib/jekyll/minibundle/environment.rb +14 -0
- data/lib/jekyll/minibundle/mini_bundle_block.rb +12 -10
- data/lib/jekyll/minibundle/mini_stamp_tag.rb +12 -2
- data/lib/jekyll/minibundle/stamp_file.rb +20 -16
- data/lib/jekyll/minibundle/version.rb +1 -1
- data/test/fixture/site/_bin/with_count +13 -0
- data/test/integration/minibundle_development_mode_test.rb +31 -17
- data/test/integration/minibundle_production_mode_test.rb +68 -30
- data/test/integration/ministamp_test.rb +33 -13
- data/test/support/fixture_config.rb +7 -3
- data/test/support/test_case.rb +40 -9
- data/test/unit/asset_bundle_test.rb +1 -1
- data/test/unit/bundle_file_test.rb +57 -0
- data/test/unit/stamp_file_test.rb +42 -0
- metadata +18 -19
- data/Readme.md +0 -135
data/Readme.md
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
# Jekyll Minibundle plugin
|
2
|
-
|
3
|
-
A minimalistic plugin for bundling assets to
|
4
|
-
[Jekyll](https://github.com/mojombo/jekyll)'s site generation
|
5
|
-
directory.
|
6
|
-
|
7
|
-
In addition to the plugin itself, you only need your asset bundling
|
8
|
-
tool of choice. The plugin needs no other configuration than setting
|
9
|
-
an environment variable. There are no gem dependencies.
|
10
|
-
|
11
|
-
Tested with Ruby MRI 1.9.3. Ruby 1.8 is *not* supported.
|
12
|
-
|
13
|
-
[](http://travis-ci.org/tkareine/jekyll-minibundle)
|
14
|
-
|
15
|
-
# Features
|
16
|
-
|
17
|
-
There are two features: asset stamping with MD5 digest over the
|
18
|
-
contents of the asset, and asset bundling combined with the first
|
19
|
-
feature.
|
20
|
-
|
21
|
-
You still need a separate bundling tool, such as
|
22
|
-
[UglifyJS2](https://github.com/mishoo/UglifyJS2) to do the actual work
|
23
|
-
of bundling (concatenation, minification). There are no other
|
24
|
-
dependencies.
|
25
|
-
|
26
|
-
Why is this good? Well, a unique content specific identifier in asset
|
27
|
-
filename is the best way to handle web caching, because you can allow
|
28
|
-
caching the asset for forever. Calculating MD5 digest over the
|
29
|
-
contents of the asset is fast and the resulting digest is reasonably
|
30
|
-
unique to be generated automatically.
|
31
|
-
|
32
|
-
Asset bundling is good for reducing the number of requests to server
|
33
|
-
upon page load. It also allows minification for stylesheets and
|
34
|
-
JavaScript sources, which makes asset sizes smaller and thus faster to
|
35
|
-
load over network.
|
36
|
-
|
37
|
-
# Usage
|
38
|
-
|
39
|
-
The plugin is shipped as a
|
40
|
-
[RubyGem](https://rubygems.org/gems/jekyll-minibundle):
|
41
|
-
|
42
|
-
gem install jekyll-minibundle
|
43
|
-
|
44
|
-
Add file `_plugins/minibundle.rb` to your Jekyll site project with
|
45
|
-
this line:
|
46
|
-
|
47
|
-
require 'jekyll/minibundle'
|
48
|
-
|
49
|
-
## Asset stamping
|
50
|
-
|
51
|
-
Asset stamping is intended to be used together with
|
52
|
-
[Compass](http://compass-style.org/) and other similar asset
|
53
|
-
generation tools that have their own configuration for input sources.
|
54
|
-
|
55
|
-
Configure Compass to take inputs from `_assets/styles/*.scss` and to
|
56
|
-
put output to `_tmp/site.css`. Use `ministamp` tag to copy the
|
57
|
-
processed style asset to the generated site:
|
58
|
-
|
59
|
-
<link href="{% ministamp _tmp/site.css assets/site.css %}" rel="stylesheet" media="screen, projection">
|
60
|
-
|
61
|
-
Output, containing the MD5 digest of the file in the filename:
|
62
|
-
|
63
|
-
<link href="assets/site-390be921ee0eff063817bb5ef2954300.css" rel="stylesheet" media="screen, projection">
|
64
|
-
|
65
|
-
This feature does not require any external tools.
|
66
|
-
|
67
|
-
## Asset bundling
|
68
|
-
|
69
|
-
This is a straightforward way to bundle assets with any tool that
|
70
|
-
supports reading input from STDIN and writing the output to STDOUT.
|
71
|
-
You write the configuration for input sources directly into the
|
72
|
-
content file where you want the markup tag for the bundle file to
|
73
|
-
appear. The outcome will be a markup tag containing the path to the
|
74
|
-
bundle file, and the generated site will have the bundle file in that
|
75
|
-
path. The MD5 digest of the file will be included in the filename.
|
76
|
-
|
77
|
-
Place `minibundle` block with configuration into your content file
|
78
|
-
where you want the generated markup to appear. For example, to bundle
|
79
|
-
a set of JavaScript sources:
|
80
|
-
|
81
|
-
{% minibundle js %}
|
82
|
-
source_dir: _assets/scripts
|
83
|
-
destination_path: assets/site
|
84
|
-
assets:
|
85
|
-
- dependency
|
86
|
-
- app
|
87
|
-
attributes:
|
88
|
-
id: my-scripts
|
89
|
-
{% endminibundle %}
|
90
|
-
|
91
|
-
Then, specify the command for launching your favorite bundling tool in
|
92
|
-
`$JEKYLL_MINIBUNDLE_CMD_JS` environment variable. For example, when
|
93
|
-
launching Jekyll:
|
94
|
-
|
95
|
-
$ JEKYLL_MINIBUNDLE_CMD_JS='./node_modules/.bin/uglifyjs --' jekyll
|
96
|
-
|
97
|
-
You can pass custom attributes to the generated markup with
|
98
|
-
`attributes` map in the configuration.
|
99
|
-
|
100
|
-
Output in the content file:
|
101
|
-
|
102
|
-
<script src="assets/site-8e764372a0dbd296033cb2a416f064b5.js" type="text/javascript" id="my-scripts"></script>
|
103
|
-
|
104
|
-
For bundling CSS assets, you use `css` as the argument to `minibundle` block:
|
105
|
-
|
106
|
-
{% minibundle css %}
|
107
|
-
source_dir: _assets/styles
|
108
|
-
destination_path: assets/site
|
109
|
-
assets:
|
110
|
-
- reset
|
111
|
-
- common
|
112
|
-
attributes:
|
113
|
-
media: screen
|
114
|
-
{% endminibundle %}
|
115
|
-
|
116
|
-
And then specify the command for launching bundling in
|
117
|
-
`$JEKYLL_MINIBUNDLE_CMD_CSS` environment variable.
|
118
|
-
|
119
|
-
## Development mode
|
120
|
-
|
121
|
-
For your development workflow, asset bundling can get in the way. To
|
122
|
-
remedy this, you can instruct the library into development mode. Then,
|
123
|
-
`minibundle` block will not bundle assets, but copy each asset as-is
|
124
|
-
to the destination directory under the path specified in
|
125
|
-
`destination_path` configuration setting.
|
126
|
-
|
127
|
-
$ JEKYLL_MINIBUNDLE_MODE=development jekyll --auto --server
|
128
|
-
|
129
|
-
# Example site
|
130
|
-
|
131
|
-
See the contents of `test/fixture/site` directory.
|
132
|
-
|
133
|
-
# License
|
134
|
-
|
135
|
-
MIT. See `License.txt`.
|