dependents / node-sass-lookup

Get the file associated with a Sass import
MIT License
1 stars 4 forks source link

Update directory handling (check partials and allow multiple director… #2

Closed alreece45 closed 7 years ago

alreece45 commented 7 years ago

Currently, the only directory checked for partials is the directory of filename, directory is not checked for partials.

This pull request checks directory and will also check multiple directories (if its not a string).

The function returned a value, even when a file couldn't be found-- so this function does the same, but only if directory is a string.

The patch and the testing could probably use some work. Critique welcome.

mrjoelkemp commented 7 years ago

@alreece45 Thanks so much for contributing!

directory is not checked for partials.

Is that expected behavior of the sass import loader? A partial is usually either a filename (at which point it's local to the directory of the current file), or it's a relative path (which is still relative about the current file). I'm definitely open to improving the library, I just want it to be according to spec.

alreece45 commented 7 years ago

I don't know of a spec on @import behavior, but it seems to match the behavior of both sass and libsass

Other notes on their import behavior:

As far as their import behavior:

sass appears to create a importer for each path, asks each importer to find[1][2] a path, which ends up using possible_paths()

libsass's parser's appears to call Sass::Parser::parse_imports(). When not using a standard importer, it appears to call import_url, which calls Sass::Context::load_import. find_include() is run for each path,.ends up at Sass::File::resolve_includes-- which attempts to load partials.

mrjoelkemp commented 7 years ago

@alreece45 Thanks a ton for your great work here. I updated the readme and released a new minor version with the change. Thanks for contributing!

alreece45 commented 7 years ago

@mrjoelkemp Do you want to aim at matching the other behavior? The ones regarding ambiguities and extension checking.

mrjoelkemp commented 7 years ago

I don't have a strong opinion really. If you think it's valuable to address then 👍