Add jekyll-minifier
(#668)
* Remove obsolete plugins * Add `jekyll-minifier` * Add `JEKYLL_ENV=production`
This commit is contained in:
parent
e40bc98f47
commit
503bfc235a
5
Gemfile
5
Gemfile
@ -5,18 +5,17 @@ group :jekyll_plugins do
|
||||
gem 'jekyll-diagrams'
|
||||
gem 'jekyll-email-protect'
|
||||
gem 'jekyll-feed'
|
||||
gem 'jekyll-github-metadata'
|
||||
gem 'jekyll-imagemagick'
|
||||
gem 'jekyll-minifier'
|
||||
gem 'jekyll-paginate-v2'
|
||||
gem 'jekyll-scholar'
|
||||
gem 'jekyll-sitemap'
|
||||
gem 'jekyll-target-blank'
|
||||
gem 'jekyll-twitter-plugin'
|
||||
gem 'jemoji'
|
||||
gem 'mini_racer'
|
||||
gem 'unicode_utils'
|
||||
gem 'webrick'
|
||||
gem 'htmlcompressor'
|
||||
gem 'htmlbeautifier'
|
||||
end
|
||||
group :other_plugins do
|
||||
gem 'httparty'
|
||||
|
24
_config.yml
24
_config.yml
@ -156,8 +156,8 @@ plugins:
|
||||
- jekyll-diagrams
|
||||
- jekyll-email-protect
|
||||
- jekyll-feed
|
||||
- jekyll-github-metadata
|
||||
- jekyll-imagemagick
|
||||
- jekyll-minifier
|
||||
- jekyll-paginate-v2
|
||||
- jekyll/scholar
|
||||
- jekyll-sitemap
|
||||
@ -171,27 +171,15 @@ defaults:
|
||||
path: "assets/**/*.*"
|
||||
values:
|
||||
sitemap: false
|
||||
# Extras
|
||||
github: [metadata]
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Jekyll optimization
|
||||
# Jekyll Minifier
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# HTML remove comments (<!-- .... -->)
|
||||
remove_HTML_comments: false
|
||||
|
||||
# HTML beautifier (_plugins/beautify.rb).
|
||||
# Source: https://github.com/threedaymonk/htmlbeautifier
|
||||
beautify: false # This function has conflict with the code snippets, they can be displayed incorrectly
|
||||
|
||||
# HTML minify (_plugins/minify.rb).
|
||||
# Source: https://www.ffbit.com/blog/2021/03/17/html-minification-in-jekyll.html
|
||||
minify: false
|
||||
|
||||
# CSS/SASS minify
|
||||
sass:
|
||||
style: compressed
|
||||
jekyll-minifier:
|
||||
exclude: ['robots.txt']
|
||||
uglifier_args:
|
||||
harmony: true
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Jekyll Archives
|
||||
|
@ -1,27 +0,0 @@
|
||||
require 'htmlbeautifier'
|
||||
|
||||
module Jekyll
|
||||
module StripHTML
|
||||
def beautify(content)
|
||||
if beautify_enabled?
|
||||
content = HtmlBeautifier.beautify(content)
|
||||
else
|
||||
content
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def beautify_enabled?
|
||||
config = @context.registers[:site].config
|
||||
true?(config['beautify'])
|
||||
end
|
||||
|
||||
def true?(obj)
|
||||
obj.to_s.downcase == 'true'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_filter(Jekyll::StripHTML)
|
@ -1,28 +0,0 @@
|
||||
# Source: https://www.ffbit.com/blog/2021/03/17/html-minification-in-jekyll.html
|
||||
require 'htmlcompressor'
|
||||
|
||||
module Jekyll
|
||||
module MinifyFilter
|
||||
def minify(content)
|
||||
if minify_enabled?
|
||||
compressor = HtmlCompressor::Compressor.new
|
||||
compressor.compress content
|
||||
else
|
||||
content
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def minify_enabled?
|
||||
config = @context.registers[:site].config
|
||||
true?(config['minify'])
|
||||
end
|
||||
|
||||
def true?(obj)
|
||||
obj.to_s.downcase == 'true'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_filter(Jekyll::MinifyFilter)
|
@ -91,6 +91,9 @@ then
|
||||
fi
|
||||
git checkout -b $DEPLOY_BRANCH
|
||||
|
||||
# Export JEKYLL_ENV=production
|
||||
export JEKYLL_ENV=production
|
||||
|
||||
# Build site
|
||||
bundle exec jekyll build
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user