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

Import fails when filename is "css" (less thinks thats the extension) #2998

Closed
felixsanz opened this issue Dec 1, 2016 · 5 comments
Closed

Comments

@felixsanz
Copy link

felixsanz commented Dec 1, 2016

For example, parsing this:

@import "syntax/c";
@import "syntax/css";
@import "syntax/go";

CSS import is ignored and the line appears in the CSS result as @import "syntax/css";. (It's not resolved the import)

This is fixed changing it to @import "syntax/css.less";.


Documentation here: http://lesscss.org/features/#import-directives-feature-file-extensions

Says:

@import statements may be treated differently by Less depending on the file extension:

If the file has a .css extension it will be treated as CSS and the @import statement left as-is (see the inline option below).
If it has any other extension it will be treated as Less and imported.
If it does not have an extension, .less will be appended and it will be included as a imported Less file.

So it's clearly an issue failing to identify the extension for syntax/css (which is syntax/css.less)

@felixsanz felixsanz changed the title Import fails on weird use case Import fails when filename is "css" (less thinks thats the extension) Dec 1, 2016
@seven-phases-max
Copy link
Member

Yes, it seems to be a regression of one of early 2.0.x branches (before 2.x it worked as you expect).

@seven-phases-max
Copy link
Member

If I'm not mistaken the change was made to support imports like:

@import "https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700";

that otherwise would result in a broken (less) import (obviously since there's no css extension in that url).
So the fix is easy but requires documenting the breaking cases. I.e. all such urls to appear as:

@import (css) "https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700";

@seven-phases-max
Copy link
Member

seven-phases-max commented Jun 10, 2017

So per above observation adding "NeedsDecision" label, as the trick is that it's not hard to guess that count of such "font" urls used out there vastly outnumbers the use-case of the initial post and then it's actually questionable if it's better to keep current behaviour and change the docs instead.

@matthew-dean
Copy link
Member

Support for this very thing was added to 3.x. #2955

It could probably get merged into a 2.x release if important.

@seven-phases-max
Copy link
Member

So I'm closing as fixed in #2955.

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

No branches or pull requests

3 participants