Skip to content

Instantly share code, notes, and snippets.

@joefiorini
Created May 12, 2013 15:28
Show Gist options
  • Save joefiorini/5563919 to your computer and use it in GitHub Desktop.
Save joefiorini/5563919 to your computer and use it in GitHub Desktop.
A custom importer for loading bower components (regardless of CSS or SCSS) into Sass templates. Use with the bower! prefix like: @import "bower!normalize-css/normalize";
module Sass
module Importers
class BowerImporter < Sass::Importers::Filesystem
SUPPORTED_EXTNAMES = ["css", "scss", "sass"]
protected
def extensions
super.merge('css' => :scss)
end
def possible_files(name)
if name.start_with? "bower!"
name.sub!(/^bower!/, "")
path = File.join(@root, name)
SUPPORTED_EXTNAMES.each do |extname|
lookup = "#{path}.#{extname}"
if File.exist? lookup
return [[lookup, extensions[extname]]]
end
end
else
super
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment