class Sprockets::Utils::Gzip
def compress(target)
Does not modify the target asset.
the same name plus a `.gz` extension in the same folder as the original.
Compresses the target asset's contents and puts it into a file with
Private: Generates a gzipped file based off of reference asset.
def compress(target) mtime = PathUtils.stat(target).mtime PathUtils.atomic_write("#{target}.gz") do |f| gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION) gz.mtime = mtime gz.write(@source) gz.close File.utime(mtime, mtime, f.path) end nil end