Skip to content

Instantly share code, notes, and snippets.

@topher6345
Created November 30, 2014 02:30
Show Gist options
  • Save topher6345/6c8f21c406a91fc18727 to your computer and use it in GitHub Desktop.
Save topher6345/6c8f21c406a91fc18727 to your computer and use it in GitHub Desktop.
GZIP all files in a built Jekyll Project.
require 'zlib'
Dir[File.join('_site', '**', '*')].reject { |p| File.directory? p }
.each do |oldfile|
old_file_text = File.read(oldfile)
open(oldfile, 'wb') do |file|
gzip = Zlib::GzipWriter.new(file)
gzip << old_file_text
gzip.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment