Skip to content

Instantly share code, notes, and snippets.

Embed
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
end
desc "Compiles SASS using Compass"
task 'sass:compile' do
system 'compass compile'
end
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"
end
desc "Removes all compiled and bundled assets"
task :clean => :environment do
files = []
files << ['assets']
files << ['javascripts', 'compiled']
files << ['stylesheets', 'compiled']
files = files.map { |path| Dir[Rails.root.join('public', *path, '*.*')] }.flatten
puts "Removing:"
files.each do |file|
puts " #{file.gsub(Rails.root.to_s + '/', '')}"
end
File.delete *files
end
end
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
You can’t perform that action at this time.