diff --git a/src/file.cpp b/src/file.cpp index d99f2c62c2..826c8113ce 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -324,6 +324,8 @@ namespace Sass { // (2) underscore + given // (3) underscore + given + extension // (4) given + extension + // (5) given + _index.scss + // (6) given + _index.sass std::vector resolve_includes(const std::string& root, const std::string& file, const std::vector& exts, const std::vector& d_exts) { std::string filename = join_paths(root, file); @@ -363,6 +365,25 @@ namespace Sass { abs_path = join_paths(root, rel_path); if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path }); } + // index files + if (includes.size() == 0) { + // ignore directories that look like @import'able filename + for(auto ext : exts) { + if (ends_with(name, ext)) return includes; + } + // next test underscore index exts + for(auto ext : exts) { + rel_path = join_paths(base, join_paths(name, "_index" + ext)); + abs_path = join_paths(root, rel_path); + if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path }); + } + // next test plain index exts + for(auto ext : exts) { + rel_path = join_paths(base, join_paths(name, "index" + ext)); + abs_path = join_paths(root, rel_path); + if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path }); + } + } // nothing found return includes; }