-
Notifications
You must be signed in to change notification settings - Fork 3.4k
!important for variables #1401
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
Comments
The declaration syntax feels clunky. Can you give an example use-case where you'd need to declare variables twice? |
I'm working on a framework at the moment, where I want to be able to merge everything into one css file but also to process every less file as it's own css file. For example I have That itself is no problem, but if one of the modules is now using paths, everything is screwed up either for the mergefile or the module files. While I can't think of any way to go around this, while the variables have to be included in each less file. |
not sure what the problem is with paths? Have you looked at the rootpath option and relativePaths option? foryour other problem, I would do this ?
|
I suspect this is just yet another variation of "default variables" request. |
You know what? The more I think about it, the more I think it's a good idea to do something like this. However, I think it should match CSS syntax.
The use case: we already have this concept of importing a library via (reference) and then choosing what we need and essentially "overriding" what we need. It would be nice to do the same with variables. As in:
It allows the library to be (somewhat) safe from updates, as I'm not rewriting files in the library, but am still configuring it. Although, would some argue to just do:
Would that overwrite the variable in the root scope, or would bootstrap have been evaluated by then? Even so, being able to put variables at the top of files is sometimes desirable. I'm not sure everyone who has mentioned default variables is talking about this scenario, but it occurred to me a couple days ago. |
It might be still clunky to add !important to a whole stack of variables, but I think there's an argument for defining variables that take precedence over later declarations. |
yes that would overwrite the variable inside bootstrap. adding this support, I think has several downsides
I strongly suggest this feature request should be closed. |
Yes, that occurred to me as well. Hmm.... yeah, typically if there's a) another Less way to do it, and b) it adds a bunch of complexity, we tend to not add. I'm fine with closing as I don't feel strongly about it, and you do, so that's fine with me. |
@matthew-dean Yep, and don't forget that beside the standard "last definition wins" LESS behaviour (which makes SASS-like "default variable" facility to be not necessary in normal use-cases), we also have the "scoped variables" design pattern (see 1494, 1706) which does the same but also can be used in a situation when you need a "default variable" not depending on a definition/import order. So it's more like: a) LESS does not need this at all b) It already has similar feature anyway. |
Just like it works for css:
Output
Syntax Ideas
!@variable: ;
@variable: ;!important
The text was updated successfully, but these errors were encountered: