Skip to content

Instantly share code, notes, and snippets.

@fermion
Created April 24, 2009 15:53
Show Gist options
  • Save fermion/101162 to your computer and use it in GitHub Desktop.
Save fermion/101162 to your computer and use it in GitHub Desktop.
thanks @gf3
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