Skip to content

Instantly share code, notes, and snippets.

Created October 6, 2010 10:02
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Asset packaging rake task
desc "Compiles CoffeeScript using Barrista (but only if they changed)"
task 'coffee:compile' => :environment do
abort "'#{Barista::Compiler.bin_path}' is unavailable." unless Barista::Compiler.available?
Barista.compile_all! false, false
desc "Compiles SASS using Compass"
task 'sass:compile' do
system 'compass compile'
namespace :assets do
desc "Compiles all assets (CSS/JS)"
task :compile => ['coffee:compile', 'sass:compile']
desc "Bundles all assets with Jammit"
task :bundle => :environment do
system "cd #{Rails.root} && jammit"
desc "Removes all compiled and bundled assets"
task :clean => :environment do
files = []
files << ['assets']
files << ['javascripts', 'compiled']
files << ['stylesheets', 'compiled']
files = { |path| Dir[Rails.root.join('public', *path, '*.*')] }.flatten
puts "Removing:"
files.each do |file|
puts " #{file.gsub(Rails.root.to_s + '/', '')}"
File.delete *files
desc "Compiles and bundles all assets"
task :assets => ['assets:compile', 'assets:bundle']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment