Skip to content

Instantly share code, notes, and snippets.

@gf3
Forked from fermion/gist:101162
Created April 24, 2009 15:54
Show Gist options
  • Save gf3/101164 to your computer and use it in GitHub Desktop.
Save gf3/101164 to your computer and use it in GitHub Desktop.
Rake task to pack JS files.
require 'packr'
namespace :js do
desc "Pack javascript src for production environment"
task :pack => :environment do
# Files to pack
Dir.glob(File.join("public", "javascripts", "**", "*.js")).each do |filename|
puts "packing #{filename}..."
FileUtils.cp(filename, "#{filename}.orig")
js = ""
File.open(filename, "r") { |f| js = f.read }
File.open(filename, "w") { |f| f.write(Packr.pack(js, :shrink_vars => true, :private => true)) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment