Skip to content

Instantly share code, notes, and snippets.

@andypike
Created October 28, 2010 11:38
Show Gist options
  • Save andypike/651174 to your computer and use it in GitHub Desktop.
Save andypike/651174 to your computer and use it in GitHub Desktop.
Minify css and js using the yui compressor in rake
# APP_PATH is your application root path
# YUI_COMPRESSOR_PATH is the path to the yuicompressor-x.x.x.jar
# Files are replaced. Designed to run over the build artifacts on the CI server
desc "Minify the javascript and css files that are within the artifacts folder"
task :minify => [:copy_artifacts] do
#http://developer.yahoo.com/yui/compressor/
puts "Minifying javascript"
js_files = FileList["#{APP_PATH}/**/*.js"].exclude(/.min.js/)
js_files.each do |js_file|
sh "java -jar \"#{YUI_COMPRESSOR_PATH}\" #{js_file} -o #{js_file} --charset utf-8"
end
css_files = FileList["#{APP_PATH}/**/*.css"]
css_files.each do |css_file|
sh "java -jar \"#{YUI_COMPRESSOR_PATH}\" #{css_file} -o #{css_file} --charset utf-8"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment