Permalink
Browse files

Cache asset precompilation based on diff of uncompiled files

  • Loading branch information...
nthj committed Sep 5, 2012
1 parent 8b89938 commit 889d9f98b229dd999567144a4ce9e63f09a0ae47
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/language_pack/rails3.rb
@@ -42,6 +42,9 @@ def run_assets_precompile_rake_task
topic("Preparing app for Rails asset pipeline")
if File.exists?("public/assets/manifest.yml")
puts "Detected manifest.yml, assuming assets were compiled locally"
elsif precompiled_assets_are_cached?
puts "Assets already compiled, loading from cache"
cache_load "public/assets"
else
ENV["RAILS_GROUPS"] ||= "assets"
ENV["RAILS_ENV"] ||= "production"
@@ -53,6 +56,9 @@ def run_assets_precompile_rake_task
if $?.success?
log "assets_precompile", :status => "success"
puts "Asset precompilation completed (#{"%.2f" % time}s)"
puts "Caching assets"
cache_store "app/assets"
cache_store "public/assets"
else
log "assets_precompile", :status => "failure"
puts "Precompiling assets failed, enabling runtime asset compilation"
@@ -82,4 +88,9 @@ def setup_database_url_env
"#{scheme}://user:pass@127.0.0.1/dbname"
end
end
# have the assets changed since we last pre-compiled them?
def precompiled_assets_are_cached?
run("diff app/assets #{cache_base + 'app/assets'} --recursive").split("\n").length.zero?
end
end

0 comments on commit 889d9f9

Please sign in to comment.