Skip to content

Instantly share code, notes, and snippets.

@ernie
Created March 9, 2011 19:07
Show Gist options
  • Save ernie/862756 to your computer and use it in GitHub Desktop.
Save ernie/862756 to your computer and use it in GitHub Desktop.
Rake task for minifying javascripts using YUI Compressor
namespace :javascripts do
desc 'minify the javascript files residing in app/javascripts to public/javascripts'
task :minify do
RakeFileUtils.verbose false do
Dir["app/javascripts/*.js"].each do |filename|
outfile = filename.sub(/^app/, 'public').sub(/\.js$/, '.min.js')
puts "#{filename} -> #{outfile}"
sh(
'java',
'-jar',
'vendor/yuicompressor/yuicompressor-2.4.2.jar',
filename,
'-o',
outfile
)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment