jekyll-minifier 0.1.6 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05c4b7e33729ca1d8212edf77880beea2ba46396d7484696715206be29444d7d
4
- data.tar.gz: f7ecd9dbb911ba8fb5c93b3199c10c1c10e8c51d567a31a1d0a3bd055cf38d67
3
+ metadata.gz: 117cf6a5e022dd3c282ac194330042d5929e3ef4653e7c5da400b2feb6c34b7f
4
+ data.tar.gz: 36d20a781a57b322bfedbef53b22e8051515099e0555482a899513c0ff7ec593
5
5
  SHA512:
6
- metadata.gz: 21b4e5d1e805a02f9aa1825714d23d25d18a01f7cf520ac09a6465732cf145c849924627624700470825d771f059cb4173a618f1ba565e9238efb82397d8f43d
7
- data.tar.gz: 24dd387c6ca9308360c05a0cd184407fb4db7d5dae737d31a480fc27b5f5472938a2840773ab0ccea955872a31630728ea51339fb3c277cf56a71fdade493c73
6
+ metadata.gz: 22d694decf4e5c470fe9c65723b29d45837cb1061261feabe6bbff3ce30bfc512e0c414d63c43a5b5d21cd7636a0f693d40e6b64eee6dd568fbbf2ef2783b097
7
+ data.tar.gz: b6fe3b3590df38637c5a7f4dc806c04f445a4b413d9c5fd2ccde4cc76423f78dbaa91000a94f38f843a8dd0c59b206835a65c850302a67895ec45e3ee95006e2
@@ -9,5 +9,5 @@ deploy:
9
9
  repo: digitalsparky/jekyll-minifier
10
10
  language: ruby
11
11
  rvm:
12
- - 2.3.1
13
- script: bundle exec rspec spec
12
+ - 2.3.1
13
+ script: JEKYLL_ENV="production" bundle exec rspec spec
data/README.md CHANGED
@@ -8,21 +8,26 @@ This was created due to the previous minifier (jekyll-press) not being CSS3 comp
8
8
 
9
9
  Note: this is my first ever gem, I'm learning, so feedback is much appreciated.
10
10
 
11
+ ** This minifier now only runs when JEKYLL_ENV="production" is set in the enviornment **
12
+
11
13
  Easy to use, just install the jekyll-minifier gem:
12
14
 
13
15
  <pre><code>gem install jekyll-minifier</code></pre>
14
16
 
15
- Then add this to your _config.yml:
17
+ Then add this to your \_config.yml:
16
18
 
17
- <pre><code>gems:
19
+ <pre><code>plugins:
18
20
  - jekyll-minifier
19
21
  </code></pre>
20
22
 
21
23
  Optionally, you can also add exclusions using:
24
+
22
25
  <pre><code>jekyll-minifier:
23
26
  exclude: 'atom.xml' # Exclude files from processing - file name, glob pattern or array of file names and glob patterns
24
27
  </code></pre>
25
- and toggle htmlcompressor features using:
28
+
29
+ and toggle features and settings using:
30
+
26
31
  <pre><code>jekyll-minifier:
27
32
  preserve_php: true # Default: false
28
33
  remove_spaces_inside_tags: true # Default: true
@@ -44,5 +49,20 @@ and toggle htmlcompressor features using:
44
49
  preserve_line_breaks: false # Default: false
45
50
  simple_boolean_attributes: false # Default: false
46
51
  compress_js_templates: false # Default: false
52
+ preserve_patterns: # Default: (empty)
53
+ uglifier_args: # Default: (empty)
47
54
  </code></pre>
48
55
 
56
+ js_args can be found in the the uglifier documentation at listed below
57
+
58
+ Note: es6 has been implemented as experimental only via the upstream uglifier package.
59
+ See https://github.com/lautis/uglifier for more information.
60
+
61
+ To enable es6 syntax use:
62
+
63
+ <pre><code>
64
+ jekyll-minifier:
65
+ uglifier_args:
66
+ harmony: true
67
+
68
+ </code></pre>
@@ -26,13 +26,13 @@ Gem::Specification.new do |gem|
26
26
  gem.version = Jekyll::Minifier::VERSION
27
27
  end
28
28
 
29
- gem.add_dependency "jekyll", "~> 3.5"
30
- gem.add_dependency "uglifier", "~> 3.2"
31
- gem.add_dependency "htmlcompressor", "~> 0.3"
29
+ gem.add_dependency "jekyll", ">= 3.5"
30
+ gem.add_dependency "uglifier", "~> 4.1"
31
+ gem.add_dependency "htmlcompressor", "~> 0.4"
32
32
  gem.add_dependency "cssminify2", "~> 2.0"
33
33
 
34
- gem.add_development_dependency "rake", "~> 10.4"
35
- gem.add_development_dependency "rspec", "~> 2.7"
36
- gem.add_development_dependency "jekyll-paginate"
37
- gem.add_development_dependency "redcarpet"
34
+ gem.add_development_dependency "rake", "~> 12.3"
35
+ gem.add_development_dependency "rspec", "~> 3.8"
36
+ gem.add_development_dependency "jekyll-paginate", "~> 1.1"
37
+ gem.add_development_dependency "redcarpet", "~> 3.4"
38
38
  end
@@ -31,50 +31,96 @@ module Jekyll
31
31
  end
32
32
 
33
33
  def output_html(path, content)
34
- args = { remove_comments: true, compress_css: true, compress_javascript: true, preserve_patterns: [] }
35
- args[:css_compressor] = CSSminify2.new
36
- args[:javascript_compressor] = Uglifier.new
37
-
38
- opts = @site.config['jekyll-minifier']
39
-
40
- if ( !opts.nil? )
41
- args[:remove_spaces_inside_tags] = opts['remove_spaces_inside_tags'] if opts.has_key?('remove_spaces_inside_tags')
42
- args[:remove_multi_spaces] = opts['remove_multi_spaces'] if opts.has_key?('remove_multi_spaces')
43
- args[:remove_comments] = opts['remove_comments'] if opts.has_key?('remove_comments')
44
- args[:remove_intertag_spaces] = opts['remove_intertag_spaces'] if opts.has_key?('remove_intertag_spaces')
45
- args[:remove_quotes] = opts['remove_quotes'] if opts.has_key?('remove_quotes')
46
- args[:compress_css] = opts['compress_css'] if opts.has_key?('compress_css')
47
- args[:compress_javascript] = opts['compress_javascript'] if opts.has_key?('compress_javascript')
48
- args[:simple_doctype] = opts['simple_doctype'] if opts.has_key?('simple_doctype')
49
- args[:remove_script_attributes] = opts['remove_script_attributes'] if opts.has_key?('remove_script_attributes')
50
- args[:remove_style_attributes] = opts['remove_style_attributes'] if opts.has_key?('remove_style_attributes')
51
- args[:remove_link_attributes] = opts['remove_link_attributes'] if opts.has_key?('remove_link_attributes')
52
- args[:remove_form_attributes] = opts['remove_form_attributes'] if opts.has_key?('remove_form_attributes')
53
- args[:remove_input_attributes] = opts['remove_input_attributes'] if opts.has_key?('remove_input_attributes')
54
- args[:remove_javascript_protocol] = opts['remove_javascript_protocol'] if opts.has_key?('remove_javascript_protocol')
55
- args[:remove_http_protocol] = opts['remove_http_protocol'] if opts.has_key?('remove_http_protocol')
56
- args[:remove_https_protocol] = opts['remove_https_protocol'] if opts.has_key?('remove_https_protocol')
57
- args[:preserve_line_breaks] = opts['preserve_line_breaks'] if opts.has_key?('preserve_line_breaks')
58
- args[:simple_boolean_attributes] = opts['simple_boolean_attributes'] if opts.has_key?('simple_boolean_attributes')
59
- args[:compress_js_templates] = opts['compress_js_templates'] if opts.has_key?('compress_js_templates')
60
- args[:preserve_patterns] += [/<\?php.*?\?>/im] if opts['preserve_php'] == true
61
-
62
- # Potential to add patterns from YAML
63
- #args[:preserve_patterns] += opts[:preserve_patterns].map { |pattern| Regexp.new(pattern)} if opts.has_key?(:preserve_patterns)
64
- end
34
+ if ( ENV['JEKYLL_ENV'] == "production" )
35
+ html_args = { remove_comments: true, compress_css: true, compress_javascript: true, preserve_patterns: [] }
36
+ js_args = {}
37
+
38
+ opts = @site.config['jekyll-minifier']
39
+ if ( !opts.nil? )
40
+ # Javascript Arguments
41
+ js_args += opts[:uglifier_args] if opts.has_key?(:uglifier_args)
42
+
43
+ # HTML Arguments
44
+ html_args[:remove_spaces_inside_tags] = opts['remove_spaces_inside_tags'] if opts.has_key?('remove_spaces_inside_tags')
45
+ html_args[:remove_multi_spaces] = opts['remove_multi_spaces'] if opts.has_key?('remove_multi_spaces')
46
+ html_args[:remove_comments] = opts['remove_comments'] if opts.has_key?('remove_comments')
47
+ html_args[:remove_intertag_spaces] = opts['remove_intertag_spaces'] if opts.has_key?('remove_intertag_spaces')
48
+ html_args[:remove_quotes] = opts['remove_quotes'] if opts.has_key?('remove_quotes')
49
+ html_args[:compress_css] = opts['compress_css'] if opts.has_key?('compress_css')
50
+ html_args[:compress_javascript] = opts['compress_javascript'] if opts.has_key?('compress_javascript')
51
+ html_args[:simple_doctype] = opts['simple_doctype'] if opts.has_key?('simple_doctype')
52
+ html_args[:remove_script_attributes] = opts['remove_script_attributes'] if opts.has_key?('remove_script_attributes')
53
+ html_args[:remove_style_attributes] = opts['remove_style_attributes'] if opts.has_key?('remove_style_attributes')
54
+ html_args[:remove_link_attributes] = opts['remove_link_attributes'] if opts.has_key?('remove_link_attributes')
55
+ html_args[:remove_form_attributes] = opts['remove_form_attributes'] if opts.has_key?('remove_form_attributes')
56
+ html_args[:remove_input_attributes] = opts['remove_input_attributes'] if opts.has_key?('remove_input_attributes')
57
+ html_args[:remove_javascript_protocol] = opts['remove_javascript_protocol'] if opts.has_key?('remove_javascript_protocol')
58
+ html_args[:remove_http_protocol] = opts['remove_http_protocol'] if opts.has_key?('remove_http_protocol')
59
+ html_args[:remove_https_protocol] = opts['remove_https_protocol'] if opts.has_key?('remove_https_protocol')
60
+ html_args[:preserve_line_breaks] = opts['preserve_line_breaks'] if opts.has_key?('preserve_line_breaks')
61
+ html_args[:simple_boolean_attributes] = opts['simple_boolean_attributes'] if opts.has_key?('simple_boolean_attributes')
62
+ html_args[:compress_js_templates] = opts['compress_js_templates'] if opts.has_key?('compress_js_templates')
63
+ html_args[:preserve_patterns] += [/<\?php.*?\?>/im] if opts['preserve_php'] == true
64
+ html_args[:preserve_patterns] += opts[:preserve_patterns].map { |pattern| Regexp.new(pattern)} if opts.has_key?(:preserve_patterns)
65
+ end
66
+
67
+ html_args[:css_compressor] = CSSminify2.new()
68
+
69
+ if ( !js_args.nil? )
70
+ html_args[:javascript_compressor] = Uglifier.new(js_args)
71
+ else
72
+ html_args[:javascript_compressor] = Uglifier.new()
73
+ end
65
74
 
66
- compressor = HtmlCompressor::Compressor.new(args)
67
- output_file(path, compressor.compress(content))
75
+ compressor = HtmlCompressor::Compressor.new(html_args)
76
+ output_file(path, compressor.compress(content))
77
+ else
78
+ output_file(path, content)
79
+ end
68
80
  end
69
81
 
70
82
  def output_js(path, content)
71
- compressed = Uglifier.new
72
- output_file(path, compressed.compile(content))
83
+ if ( ENV['JEKYLL_ENV'] == "production" )
84
+ opts = @site.config['jekyll-minifier']
85
+ compress = true
86
+ if ( !opts.nil? )
87
+ compress = opts['compress_javascript'] if opts.has_key?('compress_javascript')
88
+ js_args += opts[:js_args] if opts.has_key?(:js_args)
89
+ end
90
+
91
+ if ( compress )
92
+ if ( !js_args.nil? )
93
+ compressor = Uglifier.new(js_args)
94
+ else
95
+ compressor = Uglifier.new()
96
+ end
97
+
98
+ output_file(path, compressed.compile(content))
99
+ else
100
+ output_file(path, content)
101
+ end
102
+ else
103
+ output_file(path, content)
104
+ end
73
105
  end
74
106
 
75
107
  def output_css(path, content)
76
- compressor = CSSminify2.new
77
- output_file(path, compressor.compress(content))
108
+ if ( ENV['JEKYLL_ENV'] == "production" )
109
+ opts = @site.config['jekyll-minifier']
110
+ compress = true
111
+ if ( !opts.nil? )
112
+ compress = opts['compress_css'] if opts.has_key?('compress_css')
113
+ end
114
+ if ( compress )
115
+ compressor = CSSminify2.new()
116
+ output_file(path, compressor.compress(content))
117
+ else
118
+ output_file(path, content)
119
+ end
120
+ else
121
+ output_file(path, content)
122
+ end
123
+
78
124
  end
79
125
 
80
126
  private
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Minifier
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
@@ -1,19 +1,24 @@
1
- markdown: redcarpet
2
- highlighter: pygments
3
- title: Example.com
4
- tagline: 'Example!'
5
- description: ''
6
- url: https://example.com
7
- paginate: 10
8
- category_dir: /
9
- category_title_prefix: ''
10
- permalink: :categories/:title.html
11
- timezone: Australia/Perth
1
+ markdown: redcarpet
2
+ highlighter: pygments
3
+ title: Example.com
4
+ tagline: "Example!"
5
+ description: ""
6
+ url: https://example.com
7
+ paginate: 10
8
+ category_dir: /
9
+ category_title_prefix: ""
10
+ permalink: :categories/:title.html
11
+ timezone: Australia/Perth
12
12
  author:
13
- name: 'Example'
14
- email: 'example@example.com'
13
+ name: "Example"
14
+ email: "example@example.com"
15
15
  menu:
16
- - { url: 'https://www.github.com/example/', name: 'GitHub', nofollow: true, newwindow: true }
16
+ - {
17
+ url: "https://www.github.com/example/",
18
+ name: "GitHub",
19
+ nofollow: true,
20
+ newwindow: true,
21
+ }
17
22
  plugins:
18
- - jekyll-minifier
19
- - jekyll-paginate
23
+ - jekyll-minifier
24
+ - jekyll-paginate
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-minifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - DigitalSparky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-24 00:00:00.000000000 Z
11
+ date: 2018-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.5'
27
27
  - !ruby/object:Gem::Dependency
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.2'
33
+ version: '4.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.2'
40
+ version: '4.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: htmlcompressor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.3'
47
+ version: '0.4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.3'
54
+ version: '0.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cssminify2
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,56 +72,56 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.4'
75
+ version: '12.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.4'
82
+ version: '12.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '2.7'
89
+ version: '3.8'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '2.7'
96
+ version: '3.8'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: jekyll-paginate
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '1.1'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '1.1'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: redcarpet
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '3.4'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '3.4'
125
125
  description: Jekyll Minifier using htmlcompressor for html, uglifier for js and css
126
126
  email:
127
127
  - matthew@spurrier.com.au
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  version: '0'
175
175
  requirements: []
176
176
  rubyforge_project:
177
- rubygems_version: 2.7.6
177
+ rubygems_version: 2.7.8
178
178
  signing_key:
179
179
  specification_version: 2
180
180
  summary: Jekyll Minifier for html, css, and javascript