-
-
Save gf3/101164 to your computer and use it in GitHub Desktop.
Rake task to pack JS files.
This file contains hidden or 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
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