-
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
@include .css file contents #560
Comments
I actually think the way LESS works is more intuitive, because, alternatively, if you WANTED to preserve your CSS import statements, how would you do it? Preserving CSS imports allows you to maintain backward compatibility on projects, or to import CSS files which may change, or may be generated dynamically. In some cases, an imported CSS file may change on a daily basis (auto-generated as a result of a PHP script, for example), yet the LESS files may be compiled once. Allowing both import behaviors (merge and preserve) is an elegant solution. |
I think I misinterpreted this question originally. It's actually not a bad idea. |
my only gripe with this feature is that we already have If we don't think its confusing, then |
Yeah, @import-once and @import-multiple don't make sense to me. How did those come about? It's another keyword, yes, but it still seems like a simpler and more elegant option. You're explicitly triggering the parser rather than hackishly triggering it using text matches. |
@MatthewDL and/or @agatronic I have a potential solution for this I'd like to propose that might also resolve a number of other Issues. I think it's a pretty strong idea, but I'm not sure if it's inline with the direction you guys want to go with Less. But before I just put it up here as a proposal I wanted to see if you (and by proxy @cloudhead) would prefer for me to socialize my suggestions with you first. (I submitted the accepted syntax for the ":extends" feature). Or if you want I can just put it up in a new issue with a link back to this one. |
@jonschlinkert I prefer it public so other people can particpate. You could just put a comment here? If we agree we can always copy it into a new issue and close the old ones.. or create a new issue, thats fine. Look forward to hear your suggestion. |
Awesome, will do. thanks |
I've also thought that it would be nice to have CSS files imported and concatenated the same was as LESS files, so I like this request but I'm not a fan of the specific method suggested by the OP. Even though their suggested use for I started a new issue to make my proposal here: #1134 because it goes beyond the scope of this request. However, if the solution I proposed in the other Issue isn't attractive, there are still other reasons I think we should try to find alternatives to using
Also, if the suggestions here don't cut it, then I suggest that we at least look at implementing something less hard-coded than In any case, I don't like the idea of
Unless of course I'm completely missing something and there is a pragmatic reason why |
I think the fact that @import isn't import once by default has been discussed as simply being an oversight. It seems intuitively like it should be the default behavior. @include was a suggestion as simply an alias for @import, with the exception that @import tries to "smart guess" whether to compile the file or not. If it doesn't end in ".less", it spits it out in the resulting CSS. However, in some cases, the LESS file extension may not be .less for a variety of reasons. Rather than try to guess / circumvent all the reasons, it makes sense to be able to explicitly say: "Compile this file!" without a bunch of fluff or attaching URL fragments or a bunch of special text matching. That's not to say that @include is the only option. We could also do things like explicitly declaring file mime type at the top of a file that the parser looks at, I dunno. There's a lot of ways to solve the problem, but I consider @include more elegant that doing things like |
I see your point, that makes sense. I guess my point is that a more powerful approach would allow you to set contexts on the You can already do this with CSS:
That syntax is just begging to be used for what we're talking about... But we could also do these:
And if we're going to throw out convention altogether, how about arrays?:
And any of the concepts for context that I listed should still apply (I like contexts because they let me decide later what I want to do with the files in that context):
and so on... I just don't think |
Man, your brain needs to be here more often. I think you make some great points. One of the things about LESS that we try to preserve (because of @cloudhead's directive), is that LESS be as CSS-like is possible. Not so extreme that it becomes awkward, but if there's a similar construct in CSS, we model after that. So, of those options, I find However, it's opposite seems awkward:
What we mean with the second is not "turn into LESS" or "turn into CSS". What we really mean is compile inline or preserve @import behavior (which also means placing @imports at the top of the compiled file, per the spec. So it might be better to have something like:
What do you think? |
Oh, and obviously "compile" is optional and default with .less files, and "no-compile" would be optional and default with .css files. |
Yeah I definitely prefer that direction, but I don't feel strongly about any particular implementation. I liked that idea initially because I it seemed clean, but I'll think about it and let you know if any real pros or cons come to mind. (and thanks for the compliment!) |
moving discussion to a single issue #1185 |
I think @include method should be implemented. Sometimes there is a need to include .css file contents in compiled file while there is no possibility to change included file's extension, here is an example situation:
let's assume a CSS project that has a submodule which refers to some remote repository (let's take normalize.css as an example)
.less file needs to @include normalize.css, while it's not possible to rename normalize.css to normalize.less locally as the possibility to pull submodule's remote normalize.css in future will be lost.
Hope that makes sense..
The text was updated successfully, but these errors were encountered: