jekyll-assets 3.0.7 → 3.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/README.md +71 -8
- data/Rakefile +1 -0
- data/lib/jekyll-assets.rb +1 -2
- data/lib/jekyll/assets/compressors/sassc.rb +32 -0
- data/lib/jekyll/assets/compressors/scss.rb +30 -0
- data/lib/jekyll/assets/compressors/uglify.rb +30 -0
- data/lib/jekyll/assets/config.rb +1 -1
- data/lib/jekyll/assets/default.rb +1 -2
- data/lib/jekyll/assets/env.rb +1 -38
- data/lib/jekyll/assets/extensible.rb +1 -0
- data/lib/jekyll/assets/hook.rb +32 -79
- data/lib/jekyll/assets/html.rb +1 -6
- data/lib/jekyll/assets/patches/functions.rb +5 -7
- data/lib/jekyll/assets/plugins/alternates.rb +79 -0
- data/lib/jekyll/assets/plugins/font-awesome.rb +0 -1
- data/lib/jekyll/assets/plugins/html/pic.rb +1 -1
- data/lib/jekyll/assets/plugins/liquid.rb +1 -1
- data/lib/jekyll/assets/plugins/prefixer.rb +1 -1
- data/lib/jekyll/assets/plugins/proxy/magick.rb +10 -2
- data/lib/jekyll/assets/plugins/searcher.rb +1 -1
- data/lib/jekyll/assets/plugins/srcmap.rb +47 -0
- data/lib/jekyll/assets/plugins/srcmap/css.rb +35 -0
- data/lib/jekyll/assets/plugins/srcmap/javascript.rb +29 -0
- data/lib/jekyll/assets/plugins/srcmap/writer.rb +187 -0
- data/lib/jekyll/assets/tag.rb +2 -2
- data/lib/jekyll/assets/utils.rb +35 -18
- data/lib/jekyll/assets/version.rb +1 -1
- data/lib/jekyll/assets/writer.rb +30 -33
- metadata +11 -7
- data/lib/jekyll/assets/map.rb +0 -57
- data/lib/jekyll/assets/map/css.rb +0 -43
- data/lib/jekyll/assets/map/javascript.rb +0 -43
- data/lib/jekyll/assets/map/writer.rb +0 -192
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 639668c433fd9e421070ad3440a0f5122302ac2cbccb63044ad82114bab51e36
|
4
|
+
data.tar.gz: 9fc98306dff4d217d4d0e09a32aa0a35f858125029b39e62b75eab6a7ed661b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ff42694cde71c8521ef7f03e2f2fdf8cebb9513257f2ee9a18c0c61b55d5656c217ebbef80b30f068995f63f4fe7fea482dd1698b9188bf49c7dc654e4d202b
|
7
|
+
data.tar.gz: dd946a1a0015b3397e860e98133dc692f43d9e9bfd35ce7c15001b396e6c0cf1a6164bc5d58a54d259662ad288be7386f391200a7a6014033738f1dc86859c94
|
data/Gemfile
CHANGED
@@ -20,7 +20,7 @@ group :development do
|
|
20
20
|
group :test do
|
21
21
|
gem "simplecov", require: false
|
22
22
|
gem "luna-rspec-formatters", require: false
|
23
|
-
gem "rubocop", require: false
|
23
|
+
gem "rubocop", "0.52", require: false
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -39,4 +39,5 @@ group :optionals do
|
|
39
39
|
gem "babel-transpiler", require: false
|
40
40
|
gem "bootstrap", require: false
|
41
41
|
gem "sassc", require: false
|
42
|
+
gem "crass", require: false
|
42
43
|
end
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[![Code Climate](https://img.shields.io/codeclimate/maintainability/envygeeks/jekyll-assets.svg?style=for-the-badge)](https://codeclimate.com/github/envygeeks/jekyll-assets/maintainability)
|
2
2
|
[![Code Climate](https://img.shields.io/codeclimate/c/envygeeks/jekyll-assets.svg?style=for-the-badge)](https://codeclimate.com/github/envygeeks/jekyll-assets/coverage)
|
3
3
|
[![Travis CI](https://img.shields.io/travis/envygeeks/jekyll-assets/master.svg?style=for-the-badge)](https://travis-ci.org/envygeeks/jekyll-assets)
|
4
|
-
[![Donate](https://img.shields.io/badge/-DONATE-yellow.svg?style=for-the-badge)](https://www.paypal.com/
|
4
|
+
[![Donate](https://img.shields.io/badge/-DONATE-yellow.svg?style=for-the-badge)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LKGZAWXLZ8ZPG)
|
5
5
|
![Gem Version](https://img.shields.io/gem/v/jekyll-assets.svg?style=for-the-badge)
|
6
6
|
![Gem DL](https://img.shields.io/gem/dt/jekyll-assets.svg?style=for-the-badge)
|
7
7
|
|
@@ -358,13 +358,14 @@ We have basic support for WebComponents when using Sprockets `~> 4.0.0.beta`, th
|
|
358
358
|
|
359
359
|
## Hooks
|
360
360
|
|
361
|
-
| Point
|
362
|
-
|
|
363
|
-
| `:env`
|
364
|
-
| `:env`
|
365
|
-
| `:env`
|
366
|
-
| `:config` | `:before_merge`
|
367
|
-
|
|
361
|
+
| Point | Name | Instance | Args |
|
362
|
+
| ---| --- | --- | --- |
|
363
|
+
| `:env` | `:before_init` | ✔ | ✗ |
|
364
|
+
| `:env` | `:after_init` | ✔ | ✗ |
|
365
|
+
| `:env` | `:after_write` | ✔ | ✗ |
|
366
|
+
| `:config` | `:before_merge` | ✗ | `Config{}` |
|
367
|
+
| `:asset` | `:before_compile` | ✗ | `Asset`, `Manifest` |
|
368
|
+
| `:asset` | `:after_compression` | ✗ | input{}, output{}, type=*/* |
|
368
369
|
|
369
370
|
### Example
|
370
371
|
|
@@ -402,6 +403,13 @@ end
|
|
402
403
|
```
|
403
404
|
|
404
405
|
## Default Plugins
|
406
|
+
### Google Closure Alternates
|
407
|
+
```
|
408
|
+
gem "crass"
|
409
|
+
```
|
410
|
+
|
411
|
+
Once crass is added, we will detect vendor prefixes, and add `/* @alternate */` to them, with or without compression enabled, and with protections against compression stripping.
|
412
|
+
|
405
413
|
### Font Awesome
|
406
414
|
|
407
415
|
```ruby
|
@@ -444,6 +452,11 @@ html {
|
|
444
452
|
}
|
445
453
|
```
|
446
454
|
|
455
|
+
```scss
|
456
|
+
//=require _bootstrap.css
|
457
|
+
//=require bootstrap/_reboot.css
|
458
|
+
```
|
459
|
+
|
447
460
|
### ImageMagick
|
448
461
|
|
449
462
|
```ruby
|
@@ -518,3 +531,53 @@ assets:
|
|
518
531
|
| ------ | -------------------------- | --------------- |
|
519
532
|
| `@doc` | `Nokogiri:: XML::Document` | `image/svg+xml` |
|
520
533
|
| `@doc` | `Nokogiri::HTML::Document` | `image/*` |
|
534
|
+
|
535
|
+
## Migrating from Earlier Versions
|
536
|
+
### Configuration
|
537
|
+
|
538
|
+
*Before*
|
539
|
+
|
540
|
+
```yaml
|
541
|
+
cdn: https://example.com
|
542
|
+
```
|
543
|
+
|
544
|
+
*After*
|
545
|
+
|
546
|
+
```yaml
|
547
|
+
cdn:
|
548
|
+
url: https://example.com
|
549
|
+
```
|
550
|
+
|
551
|
+
### Images/CSS/JS
|
552
|
+
|
553
|
+
*Before*
|
554
|
+
|
555
|
+
```liquid
|
556
|
+
{% css css.css %}
|
557
|
+
{% img image.jpg width:60 class:image %}
|
558
|
+
{% js js.js %}
|
559
|
+
```
|
560
|
+
|
561
|
+
*After*
|
562
|
+
|
563
|
+
```liquid
|
564
|
+
{% asset css.css %}
|
565
|
+
{% asset image.jpg width=60 class=image %}
|
566
|
+
{% asset js.js %}
|
567
|
+
```
|
568
|
+
|
569
|
+
### Custom Tags
|
570
|
+
|
571
|
+
*Before*
|
572
|
+
|
573
|
+
```liquid
|
574
|
+
<link rel="apple-touch-icon-precomposed" href="{% asset_path icon.png %}">
|
575
|
+
<link rel="apple-touch-icon-precomposed" href="{% asset_data icon.png %}">
|
576
|
+
```
|
577
|
+
|
578
|
+
*After*
|
579
|
+
|
580
|
+
```liquid
|
581
|
+
<link rel="apple-touch-icon-precomposed" href="{% asset icon.png @path %}">
|
582
|
+
<link rel="apple-touch-icon-precomposed" href="{% asset icon.png @data %}">
|
583
|
+
```
|
data/Rakefile
CHANGED
data/lib/jekyll-assets.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2017 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
5
|
+
|
6
|
+
if defined?(Sprockets::SasscCompressor)
|
7
|
+
module Jekyll
|
8
|
+
module Assets
|
9
|
+
module Compressors
|
10
|
+
class SassC < Sprockets::SasscCompressor
|
11
|
+
def call(input)
|
12
|
+
out = super(input)
|
13
|
+
Hook.trigger :asset, :after_compression do |h|
|
14
|
+
h.call(input, out, "text/css")
|
15
|
+
end
|
16
|
+
out
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# --
|
21
|
+
Sprockets.register_compressor "text/css", :assets_sassc, SassC
|
22
|
+
Hook.register :env, :after_init, priority: 3 do |e|
|
23
|
+
e.css_compressor = nil
|
24
|
+
next unless e.asset_config[:compression]
|
25
|
+
Utils.activate("sassc") do
|
26
|
+
e.css_compressor = :assets_sassc
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2017 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
5
|
+
|
6
|
+
module Jekyll
|
7
|
+
module Assets
|
8
|
+
module Compressors
|
9
|
+
class Scss < Sprockets::SassCompressor
|
10
|
+
def call(input)
|
11
|
+
out = super(input)
|
12
|
+
Hook.trigger :asset, :after_compression do |h|
|
13
|
+
h.call(input, out, "text/css")
|
14
|
+
end
|
15
|
+
out
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# --
|
20
|
+
Sprockets.register_compressor "text/css", :assets_scss, Scss
|
21
|
+
Hook.register :env, :after_init, priority: 3 do |e|
|
22
|
+
next if Utils.activate("sassc") && !Utils.old_sprockets?
|
23
|
+
|
24
|
+
e.css_compressor = nil
|
25
|
+
next unless e.asset_config[:compression]
|
26
|
+
e.css_compressor = :assets_scss
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2017 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
5
|
+
|
6
|
+
module Jekyll
|
7
|
+
module Assets
|
8
|
+
module Compressors
|
9
|
+
class Uglify < Sprockets::UglifierCompressor
|
10
|
+
def call(input)
|
11
|
+
out = super(input)
|
12
|
+
Hook.trigger :asset, :after_compression do |h|
|
13
|
+
h.call(input, out, "application/javascript")
|
14
|
+
end
|
15
|
+
out
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# rubocop:disable Metrics/LineLength
|
20
|
+
Sprockets.register_compressor "application/javascript", :assets_uglify, Uglify
|
21
|
+
Hook.register :env, :after_init, priority: 3 do |e|
|
22
|
+
e.js_compressor = nil
|
23
|
+
next unless e.asset_config[:compression]
|
24
|
+
if Utils.javascript?
|
25
|
+
e.js_compressor = :assets_uglify
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/jekyll/assets/config.rb
CHANGED
@@ -24,9 +24,8 @@ module Jekyll
|
|
24
24
|
})
|
25
25
|
end
|
26
26
|
|
27
|
-
rtn = rtn.sort_by(&:internal?)
|
28
27
|
ida = HashWithIndifferentAccess.new
|
29
|
-
rtn.each_with_object(ida) do |v, h|
|
28
|
+
rtn.sort { |v| v.internal? ? 1 : - 1 }.each_with_object(ida) do |v, h|
|
30
29
|
h.deep_merge!(v.static)
|
31
30
|
end
|
32
31
|
end
|
data/lib/jekyll/assets/env.rb
CHANGED
@@ -21,6 +21,7 @@ require_relative "logger"
|
|
21
21
|
require_relative "hook"
|
22
22
|
require_relative "tag"
|
23
23
|
require_relative "url"
|
24
|
+
require_all "compressors/*"
|
24
25
|
|
25
26
|
module Jekyll
|
26
27
|
module Assets
|
@@ -34,12 +35,6 @@ module Jekyll
|
|
34
35
|
attr_reader :asset_config
|
35
36
|
attr_reader :jekyll
|
36
37
|
|
37
|
-
# --
|
38
|
-
rb_delegate :old?, to: :"self.class"
|
39
|
-
rb_delegate :old_sprockets?, {
|
40
|
-
to: :"self.class",
|
41
|
-
}
|
42
|
-
|
43
38
|
# --
|
44
39
|
def initialize(jekyll = nil)
|
45
40
|
@asset_config = Config.new(jekyll.config["assets"] ||= {})
|
@@ -57,7 +52,6 @@ module Jekyll
|
|
57
52
|
@cache = nil
|
58
53
|
|
59
54
|
setup_sources!
|
60
|
-
enable_compression!
|
61
55
|
ignore_caches!
|
62
56
|
setup_drops!
|
63
57
|
precompile!
|
@@ -140,18 +134,6 @@ module Jekyll
|
|
140
134
|
end
|
141
135
|
end
|
142
136
|
|
143
|
-
# --
|
144
|
-
def self.old_sprockets?
|
145
|
-
@old_sprockets ||= begin
|
146
|
-
Gem::Version.new(Sprockets::VERSION) < Gem::Version.new("4.0.beta")
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
# --
|
151
|
-
class << self
|
152
|
-
alias old? old_sprockets?
|
153
|
-
end
|
154
|
-
|
155
137
|
# --
|
156
138
|
def write_all
|
157
139
|
remove_old_assets unless asset_config[:digest]
|
@@ -176,18 +158,6 @@ module Jekyll
|
|
176
158
|
jekyll.config["exclude"].uniq!
|
177
159
|
end
|
178
160
|
|
179
|
-
# --
|
180
|
-
private
|
181
|
-
def enable_compression!
|
182
|
-
self.js_compressor, self.css_compressor = nil, nil
|
183
|
-
|
184
|
-
return unless asset_config[:compression]
|
185
|
-
config = asset_config[:compressors][:uglifier].symbolize_keys
|
186
|
-
self. js_compressor = Sprockets::UglifierCompressor.new(config)
|
187
|
-
Utils.activate("sassc") { self.css_compressor = :scssc } unless old?
|
188
|
-
self.css_compressor ||= :scss
|
189
|
-
end
|
190
|
-
|
191
161
|
# --
|
192
162
|
def copy_raw!
|
193
163
|
raw_precompiles.each do |v|
|
@@ -238,13 +208,6 @@ module Jekyll
|
|
238
208
|
require_all "plugins/html/*"
|
239
209
|
require_relative "context"
|
240
210
|
|
241
|
-
require_relative "map" unless old_sprockets?
|
242
|
-
Hook.register :env, :after_init, priority: 3 do
|
243
|
-
unless old?
|
244
|
-
Map.register_on(self)
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
211
|
# --
|
249
212
|
# @see https://github.com/rails/sprockets/pull/523
|
250
213
|
# Registers a few MimeTypes since I don't think
|
data/lib/jekyll/assets/hook.rb
CHANGED
@@ -11,6 +11,21 @@ module Jekyll
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
# --
|
15
|
+
class Point
|
16
|
+
attr_accessor :block, :priority
|
17
|
+
|
18
|
+
# --
|
19
|
+
# A hook point only holds data for later, it
|
20
|
+
# really serves no other purpose for now, other
|
21
|
+
# than to make live easier for handling hooks
|
22
|
+
# and their sorting, later in stream.
|
23
|
+
# --
|
24
|
+
def initialize(priority, &block)
|
25
|
+
@priority, @block = priority, block
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
14
29
|
# --
|
15
30
|
class << self
|
16
31
|
attr_reader :points
|
@@ -19,71 +34,26 @@ module Jekyll
|
|
19
34
|
# --
|
20
35
|
@points = {
|
21
36
|
env: {
|
22
|
-
before_init:
|
23
|
-
|
24
|
-
|
25
|
-
3 => [],
|
26
|
-
},
|
27
|
-
|
28
|
-
after_init: {
|
29
|
-
1 => [],
|
30
|
-
2 => [],
|
31
|
-
3 => [],
|
32
|
-
},
|
33
|
-
|
34
|
-
after_write: {
|
35
|
-
1 => [],
|
36
|
-
2 => [],
|
37
|
-
3 => [],
|
38
|
-
},
|
37
|
+
before_init: [],
|
38
|
+
after_init: [],
|
39
|
+
after_write: [],
|
39
40
|
},
|
40
41
|
|
41
42
|
config: {
|
42
|
-
before_merge:
|
43
|
-
1 => [],
|
44
|
-
2 => [],
|
45
|
-
3 => [],
|
46
|
-
},
|
43
|
+
before_merge: [],
|
47
44
|
},
|
48
45
|
|
49
46
|
asset: {
|
50
|
-
before_compile:
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
before_read: {
|
57
|
-
1 => [],
|
58
|
-
2 => [],
|
59
|
-
3 => [],
|
60
|
-
},
|
61
|
-
|
62
|
-
after_read: {
|
63
|
-
1 => [],
|
64
|
-
2 => [],
|
65
|
-
3 => [],
|
66
|
-
},
|
67
|
-
|
68
|
-
before_write: {
|
69
|
-
1 => [],
|
70
|
-
2 => [],
|
71
|
-
3 => [],
|
72
|
-
},
|
73
|
-
|
74
|
-
after_write: {
|
75
|
-
1 => [],
|
76
|
-
2 => [],
|
77
|
-
3 => [],
|
78
|
-
},
|
47
|
+
before_compile: [],
|
48
|
+
before_read: [],
|
49
|
+
after_read: [],
|
50
|
+
after_compression: [],
|
51
|
+
before_write: [],
|
52
|
+
after_write: [],
|
79
53
|
},
|
80
54
|
|
81
55
|
liquid: {
|
82
|
-
before_render:
|
83
|
-
1 => [],
|
84
|
-
2 => [],
|
85
|
-
3 => [],
|
86
|
-
},
|
56
|
+
before_render: [],
|
87
57
|
},
|
88
58
|
}
|
89
59
|
|
@@ -97,16 +67,7 @@ module Jekyll
|
|
97
67
|
raise ArgumentError, "only give 2 points" if point.count > 2
|
98
68
|
|
99
69
|
@points[point[0]] ||= {}
|
100
|
-
@points[point[0]][point[1]] ||= {
|
101
|
-
#
|
102
|
-
}
|
103
|
-
|
104
|
-
1.upto(3).each do |i|
|
105
|
-
@points[point[0]][point[1]][i] ||= [
|
106
|
-
#
|
107
|
-
]
|
108
|
-
end
|
109
|
-
|
70
|
+
@points[point[0]][point[1]] ||= {}
|
110
71
|
@points
|
111
72
|
end
|
112
73
|
|
@@ -118,11 +79,8 @@ module Jekyll
|
|
118
79
|
# --
|
119
80
|
def self.get_point(*point)
|
120
81
|
check_point(*point)
|
121
|
-
|
122
82
|
@points[point[0]][point[1]]
|
123
|
-
.
|
124
|
-
a.concat(v)
|
125
|
-
end
|
83
|
+
.sort_by(&:priority)
|
126
84
|
end
|
127
85
|
|
128
86
|
# --
|
@@ -139,7 +97,7 @@ module Jekyll
|
|
139
97
|
"through #{point.first}"
|
140
98
|
|
141
99
|
hooks.map do |v|
|
142
|
-
block.call(v)
|
100
|
+
block.call(v.block)
|
143
101
|
end
|
144
102
|
end
|
145
103
|
|
@@ -150,17 +108,12 @@ module Jekyll
|
|
150
108
|
# @note this is what plugins should use.
|
151
109
|
# @return [nil]
|
152
110
|
# --
|
153
|
-
def self.register(*point, priority:
|
154
|
-
if priority > 3
|
155
|
-
raise ArgumentError,
|
156
|
-
"priority must be between 1 and 3"
|
157
|
-
end
|
158
|
-
|
111
|
+
def self.register(*point, priority: 48, &block)
|
159
112
|
check_point(*point)
|
113
|
+
point_ = Point.new(priority, &block)
|
160
114
|
out = @points[point[0]]
|
161
115
|
out = out[point[1]]
|
162
|
-
out
|
163
|
-
out << block
|
116
|
+
out << point_
|
164
117
|
end
|
165
118
|
|
166
119
|
# --
|