Class: Sprockets::SassImporter

Inherits:
Sass::Importers::Filesystem
  • Object
show all
Defined in:
lib/sprockets/sass_importer.rb

Overview

This custom importer adds sprockets dependency tracking on to Sass ‘@import` statements. This makes the Sprockets and Sass caching systems work together.

Instance Method Summary collapse

Constructor Details

#initialize(context, root) ⇒ SassImporter

Returns a new instance of SassImporter.



8
9
10
11
# File 'lib/sprockets/sass_importer.rb', line 8

def initialize(context, root)
  @context = context
  super root.to_s
end

Instance Method Details

#find(*args) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/sprockets/sass_importer.rb', line 21

def find(*args)
  engine = super
  if engine && (filename = engine.options[:filename])
    @context.depend_on_asset(filename)
  end
  engine
end

#find_relative(*args) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/sprockets/sass_importer.rb', line 13

def find_relative(*args)
  engine = super
  if engine && (filename = engine.options[:filename])
    @context.depend_on_asset(filename)
  end
  engine
end