Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File extension precedence #1402

Closed
jhnns opened this issue Jul 27, 2015 · 10 comments
Closed

File extension precedence #1402

jhnns opened this issue Jul 27, 2015 · 10 comments

Comments

@jhnns
Copy link

jhnns commented Jul 27, 2015

When a sass-file imports a file without extension and there are two files with the same name, which extension takes precedence? It looks like the scss always takes precedence, but I would have expected that the file with same extension as the importing file is preferred. Is this behavior specified?

Sorry, if this has been previously discussed. I could not find it in the issue search.

@saper
Copy link
Member

saper commented Jul 27, 2015

There is a discussion what the import identifier actually means at #1160. I think if it matches the existing file name, it should be used first, otherwise it would be pretty strange.

@jhnns
Copy link
Author

jhnns commented Jul 27, 2015

Ok thank you. So, this behavior is not actually intended...

@xzyfer
Copy link
Contributor

xzyfer commented Jul 27, 2015

I believe this behaviour is a hold over from before we supported the .sass syntax.

@mgreter
Copy link
Contributor

mgreter commented Aug 23, 2015

The order for searched extensions is ".scss", ".sass", ".css", ruby sass IMO has ".sass", ".scss" (css has to be enabled by some options I guess). Lookup order goes like this:

  • $file
  • _$file
  • _$file.$exts
  • $file.$exts

Latest ruby sass (at least 3.4.15) will give an error if it finds multiple files that could be imported:

Error: It's not clear which file to import for '@import "imp"'.
       Candidates:
         imp.sass
         imp.scss
       Please delete or rename all but one of these files.
        on line 1 of foo.sass

@xzyfer
Copy link
Contributor

xzyfer commented Aug 24, 2015

@mgreter I believe the issue is that our search order differs from Ruby Sass. Seems like a legitimate issue to me.

css has to be enabled by some options I guess

Ruby Sass does not support css imports and IMO this is a mistake we made.

@mgreter
Copy link
Contributor

mgreter commented Aug 24, 2015

#1341

@xzyfer
Copy link
Contributor

xzyfer commented Aug 24, 2015

I don't see what #1341 has to do with the look up order for imports?

If foo.sass and foo.scss exist the cwd then we should match the import resolution behaviour of Ruby Sass.

@mgreter
Copy link
Contributor

mgreter commented Aug 24, 2015

Other than the extension order we do match the ruby behavior exactly AFAIK!?
And latest ruby sass gives an error in that case (and the order is visible in that error) ...
To put it clear, ruby sass prefers sass even if original file is scss (from my testings)!

@xzyfer
Copy link
Contributor

xzyfer commented Aug 24, 2015

Other than the extension precedence

But that's what this issue is about.
Why wouldn't we match this behaviour? It seems inconsequential from a code point of view.

Admittedly it's an edge case, but this could affect code portability between the two engines.

@mgreter
Copy link
Contributor

mgreter commented Aug 24, 2015

If we change to .sass beeing the default extension, we probably should also default to sass syntax for unknown extensions. That's all ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants