Skip to content

Instantly share code, notes, and snippets.

@armstrjare
Created March 26, 2012 02:40
Show Gist options
  • Save armstrjare/2202542 to your computer and use it in GitHub Desktop.
Save armstrjare/2202542 to your computer and use it in GitHub Desktop.
set :asset_precompile_locations, ["config/application.rb", "app/assets"] # We check the git log for these locations to determine if recompilation necessary
# ...
namespace :assets do
task :recompile, :roles => :web do
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} GROUP=assets assets:precompile}
end
task :symlink do
run "ln -s #{shared_path}/assets #{latest_release}/public/assets"
end
task :precompile, :roles => :web, :except => { :no_release => true } do
needs_recompile = if current_revision
from = source.next_revision(current_revision)
capture("cd #{latest_release} && #{source.local.log(from)} #{asset_precompile_locations.join(' ')} | wc -l").to_i > 0
end
# Symlink public/assets to the shared assets directory.
symlink
if needs_recompile
recompile
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment