FEATURE: Add brotli compression option to precompile

To enable brotli compression on static assets use COMPRESS_BROTLI
This commit is contained in:
Sam 2016-06-07 16:55:57 +10:00
parent 3160cdf2f4
commit 8d1a556f3e

View File

@ -105,7 +105,14 @@ end
def gzip(path)
STDERR.puts "gzip #{path}"
STDERR.puts `gzip -f -c -7 #{path} > #{path}.gz`
STDERR.puts `gzip -f -c -9 #{path} > #{path}.gz`
end
def brotli(path)
if ENV['COMPRESS_BROTLI']
STDERR.puts "brotli #{path}"
STDERR.puts `brotli --quality 11 --input #{path} --output #{path}.bl`
end
end
def compress(from,to)
@ -159,6 +166,7 @@ task 'assets:precompile' => 'assets:precompile:before' do
info["size"] = File.size(path)
info["mtime"] = File.mtime(path).iso8601
gzip(path)
brotli(path)
end
end
end