Created
November 18, 2011 02:54
-
-
Save gaizka/1375433 to your computer and use it in GitHub Desktop.
Rake task to minimize js, css and manipulate its name and path
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
# Minimiza todos los .js, .css que cuelgan de /private/{stylesheets,javascripts}/**/ y | |
# los deja en /public/{stylesheets,javascripts}/**/file.min.{css,js} | |
task :default => [:compile_js, :compile_css] | |
# Dependencias: Los ficheros destino | |
task :compile_js => FileList["private/**/*.js"].pathmap("%{^private,public}X.min.js") | |
task :compile_css => FileList["private/**/*.css"].pathmap("%{^private,public}X.min.css") | |
[:js, :css].each do |type| | |
# Cada fichero destino depende del "fuente" original | |
FileList["private/**/*.#{type}"].each do |src| | |
target = src.pathmap("%{^private,public}X.min.#{type}") | |
file target => src do | |
puts "Compiling #{src} -> #{target}" | |
`java -jar yuicompressor.jar #{src} > #{target}` | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment