Skip to content
This repository
Browse code

Bring in sprockets precompile task

  • Loading branch information...
commit 5493d22419913c279a8baf38a10ffe6a9782c274 1 parent 976b2be
Joshua Peek authored August 24, 2011

Showing 1 changed file with 26 additions and 3 deletions. Show diff stats Hide diff stats

  1. 29  actionpack/lib/sprockets/assets.rake
29  actionpack/lib/sprockets/assets.rake
@@ -17,9 +17,32 @@ namespace :assets do
17 17
       Rails.application.config.action_controller.perform_caching = true
18 18
 
19 19
       config = Rails.application.config
20  
-      assets = config.assets.precompile.dup
21  
-      assets << {:to => File.join(Rails.public_path, config.assets.prefix)}
22  
-      Rails.application.assets.precompile(*assets)
  20
+      env    = Rails.application.assets
  21
+      target = Rails.root.join("public#{config.assets.prefix}")
  22
+
  23
+      if env.respond_to?(:each_logical_path)
  24
+        config.assets.precompile.each do |path|
  25
+          env.each_logical_path do |logical_path|
  26
+            if path.is_a?(Regexp)
  27
+              next unless path.match(logical_path)
  28
+            else
  29
+              next unless File.fnmatch(path.to_s, logical_path)
  30
+            end
  31
+
  32
+            if asset = env.find_asset(logical_path)
  33
+              filename = target.join(asset.digest_path)
  34
+              mkdir_p filename.dirname
  35
+              asset.write_to(filename)
  36
+              asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
  37
+            end
  38
+          end
  39
+        end
  40
+      else
  41
+        # TODO: Remove this once we're depending on sprockets beta 15
  42
+        assets = config.assets.precompile.dup
  43
+        assets << {:to => target}
  44
+        env.precompile(*assets)
  45
+      end
23 46
     end
24 47
   end
25 48
 

0 notes on commit 5493d22

Please sign in to comment.
Something went wrong with that request. Please try again.