ruby - How can I enable gzip file creation in Rails 4.2? -
as of april 14, 2015 looks .gz
file compilation removed sprockets in latest version of rails.
https://github.com/rails/sprockets/issues/26
i used these files on s3 server speed page loads, since compilation of gzip files have been removed per above thread there big question looming in mind. if using asset host, new solution having compiled .gz
files? if serving files server relatively easy, static assets hosted elsewhere , need precompilation.
anyway, has figured 1 out. temp solution if can't asset pipeline generate , upload .gz
files once did manually create them using grunt-contrib-compress(https://github.com/gruntjs/grunt-contrib-compress). know manual solutions don't scale , rather have asset pipeline take care of 1 @ deploy time.
thanks help. :)
as rake not override chains tasks, declare assets:precompile
. following solution should work without changing deployment-scripts:
#/lib/tasks/assets.rake namespace :assets # make use of rake's behaviour , chain after rails' assets:precompile. desc 'gzip assets after rails has finished precompilation' task :precompile dir['public/assets/**/*.{js,css}'].each |path| gz_path = "#{path}.gz" next if file.exist?(gz_path) zlib::gzipwriter.open(gz_path) |gz| gz.mtime = file.mtime(path) gz.orig_name = path gz.write(io.binread(path)) end end end end
Comments
Post a Comment