Skip to content

Commit

Permalink
Wrap the sass cache store in a Sprockets::Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
juanger authored and urkle committed Jun 10, 2015
1 parent 3e88f99 commit 2fe981f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compass-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Gem::Specification.new do |gem|
gem.license = "MIT"

gem.add_dependency 'compass', '~> 1.0.0'
gem.add_dependency 'sprockets', '< 2.13'
gem.add_dependency 'sprockets', '~> 3.2'
gem.add_dependency 'sass-rails', '< 5.1'
end
14 changes: 5 additions & 9 deletions lib/compass-rails/patches/sass_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
klass.class_eval do
def evaluate(context, locals, &block)
# Use custom importer that knows about Sprockets Caching
cache_store =
if defined?(Sprockets::SassCacheStore)
Sprockets::SassCacheStore.new(context.environment)
else
Sprockets::SassProcessor::CacheStore.new(sprockets_cache_store, context.environment)
end
cache_store = Sprockets::SassProcessor::CacheStore.new(sprockets_cache_store, context.environment)

paths = context.environment.paths.map { |path| CompassRails::SpriteImporter.new(path) }
paths += context.environment.paths.map { |path| sass_importer(context, path) }
Expand Down Expand Up @@ -79,14 +74,15 @@ def sass_importer_class
end

def sprockets_cache_store
case Rails.application.config.assets.cache_store
cache = case Rails.application.config.assets.cache_store
when :null_store
Sprockets::Cache::NullStore.new
when :memory_store, :mem_cache_store
Sprockets::Cache::MemoryStore.new
else
Sprockets::Cache::FileStore.new(Dir::tmpdir)
end
end
end

Sprockets::Cache.new(cache, Rails.logger)
end
end

0 comments on commit 2fe981f

Please sign in to comment.