Class: Condenser::Sass::Importer
- Inherits:
-
SassC::Importer
- Object
- SassC::Importer
- Condenser::Sass::Importer
- Defined in:
- lib/condenser/transformers/sass/importer.rb
Instance Method Summary collapse
-
#extensions ⇒ Object
Allow .css files to be @imported.
- #imports(name, base) ⇒ Object
Instance Method Details
#extensions ⇒ Object
Allow .css files to be @imported
34 35 36 |
# File 'lib/condenser/transformers/sass/importer.rb', line 34 def extensions { '.sass' => :sass, '.scss' => :scss, '.css' => :scss } end |
#imports(name, base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/condenser/transformers/sass/importer.rb', line 5 def imports(name, base) name = (name, base) env = [:condenser][:environment] accept = extensions.keys.map { |x| [:condenser][:environment].extensions[x] } [:asset][:process_dependencies] << [name, accept.map{ |i| [i] }] imports = [] env.resolve(name, accept: accept).sort_by(&:filename).each do |asset| next if asset.filename == [:filename] imports << Import.new(asset.filename, source: asset.source, source_map_path: nil) end if imports.empty? && env.npm_path package = File.join(env.npm_path, name, 'package.json') if File.exist?(package) package = JSON.parse(File.read(package)) if package['style'] imports << Import.new(name, source: File.read(File.join(env.npm_path, name, package['style'])), source_map_path: nil) end end end raise Condenser::FileNotFound, "couldn't find file '#{name}'" if imports.empty? imports end |