From 11bd9c2c4d4cbd09dd1654dd5dd264a3bebe11e0 Mon Sep 17 00:00:00 2001 From: kraoc Date: Sun, 19 Nov 2023 11:06:03 +0100 Subject: [PATCH] Redo origin --- README.md | 8 -------- lib/jekyll-minifier.rb | 18 +++++++++++++++++- lib/jekyll-minifier/version.rb | 3 ++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 01c9b75..aba0d80 100644 --- a/README.md +++ b/README.md @@ -67,11 +67,3 @@ jekyll-minifier: harmony: true - - -# Like my stuff? - -Would you like to buy me a coffee or send me a tip? -While it's not expected, I would really appreciate it. - -[![Paypal](https://www.paypalobjects.com/webstatic/mktg/Logo/pp-logo-100px.png)](https://paypal.me/MattSpurrier) Buy Me A Coffee diff --git a/lib/jekyll-minifier.rb b/lib/jekyll-minifier.rb index 74f6a0c..667e124 100644 --- a/lib/jekyll-minifier.rb +++ b/lib/jekyll-minifier.rb @@ -34,6 +34,7 @@ module Jekyll end def output_html(path, content) + if ( ENV['JEKYLL_ENV'] == "production" ) html_args = { remove_comments: true, compress_css: true, compress_javascript: true, preserve_patterns: [] } js_args = {} @@ -63,7 +64,7 @@ module Jekyll html_args[:simple_boolean_attributes] = opts['simple_boolean_attributes'] if opts.has_key?('simple_boolean_attributes') html_args[:compress_js_templates] = opts['compress_js_templates'] if opts.has_key?('compress_js_templates') html_args[:preserve_patterns] += [/<\?php.*?\?>/im] if opts['preserve_php'] == true - html_args[:preserve_patterns] += opts['preserve_patterns'].map { |pattern| Regexp.new(pattern)} if opts.has_key?('preserve_patterns') + html_args[:preserve_patterns] += opts[:preserve_patterns].map { |pattern| Regexp.new(pattern)} if opts.has_key?(:preserve_patterns) end html_args[:css_compressor] = CSSminify2.new() @@ -76,9 +77,13 @@ module Jekyll compressor = HtmlCompressor::Compressor.new(html_args) output_file(path, compressor.compress(content)) + else + output_file(path, content) + end end def output_js(path, content) + if ( ENV['JEKYLL_ENV'] == "production" ) js_args = {} opts = @site.config['jekyll-minifier'] compress = true @@ -98,9 +103,13 @@ module Jekyll else output_file(path, content) end + else + output_file(path, content) + end end def output_json(path, content) + if ( ENV['JEKYLL_ENV'] == "production" ) opts = @site.config['jekyll-minifier'] compress = true if ( !opts.nil? ) @@ -112,9 +121,13 @@ module Jekyll else output_file(path, content) end + else + output_file(path, content) + end end def output_css(path, content) + if ( ENV['JEKYLL_ENV'] == "production" ) opts = @site.config['jekyll-minifier'] compress = true if ( !opts.nil? ) @@ -126,6 +139,9 @@ module Jekyll else output_file(path, content) end + else + output_file(path, content) + end end diff --git a/lib/jekyll-minifier/version.rb b/lib/jekyll-minifier/version.rb index 105d26d..80780fa 100644 --- a/lib/jekyll-minifier/version.rb +++ b/lib/jekyll-minifier/version.rb @@ -1,5 +1,6 @@ module Jekyll module Minifier - VERSION = "0.1.8" + #VERSION = "0.1.8" + VERSION = "0.1.11" end end