Skip to content

Instantly share code, notes, and snippets.

@jpalumickas
Created October 25, 2013 07:02
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 jpalumickas/7150478 to your computer and use it in GitHub Desktop.
Save jpalumickas/7150478 to your computer and use it in GitHub Desktop.
Automatically skip assets precompiling if no changes were made.

Assets precompiling

Automatically skip assets precompiling if no changes were made.

Be sure you have lib/assets vendor/assets lib/assets/ directories !! If want to have empty directories, create .keep file !

# config/recipes/assets.rb
namespace :deploy do
namespace :assets do
task :precompile, roles: :web, except: { no_release: true } do
from = source.next_revision(current_revision)
if releases.length <= 1 || capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ lib/assets/ app/assets/ | wc -l").to_i > 0
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
end
end
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
load 'deploy/assets'
Dir['config/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment