Permalink
Browse files

Make sure generated sprites get into the asset manifest.

  • Loading branch information...
chriseppstein committed Mar 11, 2012
1 parent f78d2ce commit 05479341d10e5acb213bab5476a051946e240596
@@ -1,3 +1,5 @@
+require 'compass-rails/patches/static_compiler'
+
module Sass::Script::Functions
def generated_image_url(path, only_path = nil)
asset_url(path, Sass::Script::String.new("image"))
@@ -25,4 +27,4 @@ module Sass::Script::Functions
# Wierd that this has to be re-included to pick up sub-modules. Ruby bug?
class Sass::Script::Functions::EvaluationContext
include Sass::Script::Functions
-end
+end
@@ -16,7 +16,7 @@ def find(uri, options)
end
end
end
-
+
old
end
@@ -35,4 +35,4 @@ def resolver
end
end
-end
+end
@@ -0,0 +1,12 @@
+require 'sprockets/static_compiler'
+
+module Sprockets
+ class StaticCompiler
+ cattr_accessor :generated_sprites
+ self.generated_sprites = {}
+ def write_manifest_with_sprites(manifest)
+ write_manifest_without_sprites(manifest.merge(self.class.generated_sprites))
+ end
+ alias_method_chain :write_manifest, :sprites
+ end
+end
@@ -62,12 +62,9 @@ def compass
asset = Rails.application.assets.find_asset(filename)
pathname = Pathname.new(filename)
logical_path = filename[(Compass.configuration.images_path.length+1)..-1]
- # Force the asset into the cache so find_asset will find it.
- cached_assets = Rails.application.assets.instance_variable_get("@assets")
- cached_assets[logical_path] = cached_assets[filename] = asset
target = Pathname.new(File.join(Rails.public_path, Rails.application.config.assets.prefix))
- asset = Rails.application.assets.find_asset(logical_path)
+ Sprockets::StaticCompiler.generated_sprites[logical_path] = asset.digest_path
filename = target.join(asset.digest_path)
FileUtils.mkdir_p File.dirname(filename)
asset.write_to filename

0 comments on commit 0547934

Please sign in to comment.