From 176139da596ed067a57372684ea2a7ceec845bc9 Mon Sep 17 00:00:00 2001 From: lorin Date: Wed, 26 Aug 2020 11:44:49 +0200 Subject: [PATCH] Speed up compilation of html pages in production (#401) * speed up compilation of html pages in production * who needs all of that latex * add latex-fonts-recommended * math package * how far can we push this * just trimming off some little excess * never mind, good enough --- .travis.yml | 4 +++- Gemfile.lock | 6 +++--- lib/filters/htmlpress.rb | 11 ++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e638605..994079d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,9 @@ cache: addons: apt: packages: - - texlive-full + - texlive-latex-base + - texlive-math-extra + - texlive-xetex - lmodern branches: diff --git a/Gemfile.lock b/Gemfile.lock index a8c64f7..67a799c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,12 +5,12 @@ GEM public_suffix (>= 2.0.2, < 5.0) adsf (1.4.3) rack (>= 1.0.0, < 3.0.0) - autoprefixer-rails (9.8.6.1) + autoprefixer-rails (9.8.6.3) execjs builder (3.2.4) coderay (1.1.3) colored (1.2) - concurrent-ruby (1.1.6) + concurrent-ruby (1.1.7) cri (2.15.10) ddmemoize (1.0.0) ddmetrics (~> 1.0) @@ -121,7 +121,7 @@ GEM terminal-notifier-guard (1.7.0) thor (1.0.1) tomlrb (1.3.0) - tty-color (0.5.1) + tty-color (0.5.2) tty-command (0.9.0) pastel (~> 0.7.0) tty-platform (0.3.0) diff --git a/lib/filters/htmlpress.rb b/lib/filters/htmlpress.rb index 4f319f6..c309b6a 100644 --- a/lib/filters/htmlpress.rb +++ b/lib/filters/htmlpress.rb @@ -1,5 +1,14 @@ require 'htmlcompressor' +require 'rainpress' +require 'uglifier' + +class UglifyProxy < Uglifier + alias_method :compress, :compile +end + +JS_COMPRESSOR = UglifyProxy.new +CSS_COMPRESSOR = Rainpress Nanoc::Filter.define(:html_press) do |content, options| - HtmlCompressor::Compressor.new(compress_javascript: true, compress_css: true, remove_quotes: true, simple_boolean_attributes: true).compress content + HtmlCompressor::Compressor.new(compress_javascript: true, javascript_compressor: JS_COMPRESSOR, compress_css: true, css_compressor: CSS_COMPRESSOR, remove_quotes: true, simple_boolean_attributes: true).compress content end