-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Incorrect @import order #484
Comments
No, I don't believe you are correct. In LESS, @import statements can happen wherever, because it is actually parsing and inserting when it comes across the statement. But @imports to CSS, by necessity have behave differently because the statement will be preserved. Why? Because CSS imports MUST appear at the top of the document, even before comments. I couldn't find supporting documentation in the W3C spec, but that is stated clearly on other blogs about @import. It may mean, then, that this is a requirement for a particular browser and has become a required convention. For example, this site says the same: http://www.cssnewbie.com/css-import-rule/ My question is: Why use a CSS? If you simply change the extension to second.less, you won't have an issue. |
Valid points. I used the .css extension because I was curious how the compiler would behave. We're considering replacing all our current css with less. Since it's a rather large application, we would like to convert a few at a time. Using the .css extension would allow us to keep track of which ones have been converted or not. Anyway, there are other ways of doing that. In reading my original post over again, the expected result I posted wasn't correct. Thinking about it, I would expect this instead:
|
In my opionion @kennethjor is right, I think it would be logical to implement css files that are imported in a less file, instead of the css file being imported at the top of the by less.js generated css file. We cannot change the extension of the file, since the css file is shared with another platform (WYSIWYG editor) that does not know how to cope with .less files. In our situation we can load the css file seperately after the rest is loaded, but I can imagine that in some situations one might want to load the css file in the middle of less files, like kennethjor stated. |
Supporting documentation for "CSS imports MUST appear at the top of the document":
|
LESS should not output an |
I noticed what appears to be a bug in the import order between .css and .less files.
Suppose I have the following three files:
main.less:
first.less:
second.css:
third.less:
Executing
lessc main.less
produces the following result:The import of
second.css
is placed above the parsed content offirst.less
, which had its original import statement placed before the second one.Unless I'm overlooking something, the expected result would be:
The text was updated successfully, but these errors were encountered: