jekyll-minifier 0.1.9 → 0.1.10
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/README.md +2 -1
- data/jekyll-minifier.gemspec +1 -0
- data/lib/jekyll-minifier.rb +32 -8
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17b800e947619bc0686c3a7ff017c0cd5cad8cc2b08031146485563ec7b98c7d
|
4
|
+
data.tar.gz: 41a6b46937580a229e7d8738a8801c1e43ddeb3bf85f3b3745e6c3c8f7f24dfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66782347457ca4fcd58df60fe226a0fa7968360541fd8c728087da403674a7aad6bd257ec25cb8116028cab778235ede7351529417a08db29aa0e56ee43c5d79
|
7
|
+
data.tar.gz: 2ef075d59c416195f19a99f16f1ecd6422c9fce44824040693ec7e759218956ea37cc8380d3a2ba249027d1ac6370e0d01a38d11a78096242201d733b96b9190
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Requires Ruby 2.3+
|
4
4
|
|
5
|
-
Minifies HTML, XML, CSS, and
|
5
|
+
Minifies HTML, XML, CSS, JSON and JavaScript both inline and as separate files utilising yui-compressor and htmlcompressor.
|
6
6
|
|
7
7
|
This was created due to the previous minifier (jekyll-press) not being CSS3 compatible, which made me frown.
|
8
8
|
|
@@ -37,6 +37,7 @@ and toggle features and settings using:
|
|
37
37
|
remove_quotes: false # Default: false
|
38
38
|
compress_css: true # Default: true
|
39
39
|
compress_javascript: true # Default: true
|
40
|
+
compress_json: true # Default: true
|
40
41
|
simple_doctype: false # Default: false
|
41
42
|
remove_script_attributes: false # Default: false
|
42
43
|
remove_style_attributes: false # Default: false
|
data/jekyll-minifier.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.add_dependency "uglifier", "~> 4.1"
|
31
31
|
gem.add_dependency "htmlcompressor", "~> 0.4"
|
32
32
|
gem.add_dependency "cssminify2", "~> 2.0"
|
33
|
+
gem.add_dependency "json-minify", "~> 0.0.3"
|
33
34
|
|
34
35
|
gem.add_development_dependency "rake", "~> 12.3"
|
35
36
|
gem.add_development_dependency "rspec", "~> 3.8"
|
data/lib/jekyll-minifier.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'uglifier'
|
2
2
|
require 'htmlcompressor'
|
3
3
|
require 'cssminify2'
|
4
|
+
require 'json/minify'
|
4
5
|
|
5
6
|
module Jekyll
|
6
7
|
module Compressor
|
@@ -19,6 +20,8 @@ module Jekyll
|
|
19
20
|
else
|
20
21
|
output_js(path, context)
|
21
22
|
end
|
23
|
+
when '.json'
|
24
|
+
output_json(path, context)
|
22
25
|
when '.css'
|
23
26
|
if path.end_with?('.min.css')
|
24
27
|
output_file(path, context)
|
@@ -38,7 +41,7 @@ module Jekyll
|
|
38
41
|
opts = @site.config['jekyll-minifier']
|
39
42
|
if ( !opts.nil? )
|
40
43
|
# Javascript Arguments
|
41
|
-
js_args
|
44
|
+
js_args[:uglifier_args] = Hash[opts['uglifier_args'].map{|(k,v)| [k.to_sym,v]}] if opts.has_key?('uglifier_args')
|
42
45
|
|
43
46
|
# HTML Arguments
|
44
47
|
html_args[:remove_spaces_inside_tags] = opts['remove_spaces_inside_tags'] if opts.has_key?('remove_spaces_inside_tags')
|
@@ -66,8 +69,8 @@ module Jekyll
|
|
66
69
|
|
67
70
|
html_args[:css_compressor] = CSSminify2.new()
|
68
71
|
|
69
|
-
if ( !js_args.nil? )
|
70
|
-
html_args[:javascript_compressor] = Uglifier.new(js_args)
|
72
|
+
if ( !js_args[:uglifier_args].nil? )
|
73
|
+
html_args[:javascript_compressor] = Uglifier.new(js_args[:uglifier_args])
|
71
74
|
else
|
72
75
|
html_args[:javascript_compressor] = Uglifier.new()
|
73
76
|
end
|
@@ -81,16 +84,17 @@ module Jekyll
|
|
81
84
|
|
82
85
|
def output_js(path, content)
|
83
86
|
if ( ENV['JEKYLL_ENV'] == "production" )
|
84
|
-
|
87
|
+
js_args = {}
|
88
|
+
opts = @site.config['jekyll-minifier']
|
85
89
|
compress = true
|
86
90
|
if ( !opts.nil? )
|
87
|
-
compress
|
88
|
-
js_args
|
91
|
+
compress = opts['compress_javascript'] if opts.has_key?('compress_javascript')
|
92
|
+
js_args[:uglifier_args] = Hash[opts['uglifier_args'].map{|(k,v)| [k.to_sym,v]}] if opts.has_key?('uglifier_args')
|
89
93
|
end
|
90
94
|
|
91
95
|
if ( compress )
|
92
|
-
if ( !js_args.nil? )
|
93
|
-
compressor = Uglifier.new(js_args)
|
96
|
+
if ( !js_args[:uglifier_args].nil? )
|
97
|
+
compressor = Uglifier.new(js_args[:uglifier_args])
|
94
98
|
else
|
95
99
|
compressor = Uglifier.new()
|
96
100
|
end
|
@@ -104,6 +108,24 @@ module Jekyll
|
|
104
108
|
end
|
105
109
|
end
|
106
110
|
|
111
|
+
def output_json(path, content)
|
112
|
+
if ( ENV['JEKYLL_ENV'] == "production" )
|
113
|
+
opts = @site.config['jekyll-minifier']
|
114
|
+
compress = true
|
115
|
+
if ( !opts.nil? )
|
116
|
+
compress = opts['compress_json'] if opts.has_key?('compress_json')
|
117
|
+
end
|
118
|
+
|
119
|
+
if ( compress )
|
120
|
+
output_file(path, JSON.minify(content))
|
121
|
+
else
|
122
|
+
output_file(path, content)
|
123
|
+
end
|
124
|
+
else
|
125
|
+
output_file(path, content)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
107
129
|
def output_css(path, content)
|
108
130
|
if ( ENV['JEKYLL_ENV'] == "production" )
|
109
131
|
opts = @site.config['jekyll-minifier']
|
@@ -187,6 +209,8 @@ module Jekyll
|
|
187
209
|
else
|
188
210
|
output_js(dest_path, File.read(path))
|
189
211
|
end
|
212
|
+
when '.json'
|
213
|
+
output_json(dest_path, File.read(path))
|
190
214
|
when '.css'
|
191
215
|
if dest_path.end_with?('.min.css')
|
192
216
|
copy_file(path, dest_path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-minifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DigitalSparky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json-minify
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.3
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.3
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,8 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
188
|
- !ruby/object:Gem::Version
|
175
189
|
version: '0'
|
176
190
|
requirements: []
|
177
|
-
|
178
|
-
rubygems_version: 2.7.8
|
191
|
+
rubygems_version: 3.0.2
|
179
192
|
signing_key:
|
180
193
|
specification_version: 2
|
181
194
|
summary: Jekyll Minifier for html, css, and javascript
|