Skip to content

Instantly share code, notes, and snippets.

@gaizka
Created November 18, 2011 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaizka/1375433 to your computer and use it in GitHub Desktop.
Save gaizka/1375433 to your computer and use it in GitHub Desktop.
Rake task to minimize js, css and manipulate its name and path
# 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