Created
April 24, 2009 15:53
-
-
Save fermion/101162 to your computer and use it in GitHub Desktop.
thanks @gf3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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