Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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