Created
May 12, 2013 15:28
-
-
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";
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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