-
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
Feature request: new option for import directive: "optional" #2145
Comments
Cant you just create an empty |
It would work, yes, but it was a simplified example. There are more files concerned and the build is more complex so I didn't think of creating an empty less file for each of them. You are right but it would be nice for less to not fail the whole compiling process just because one file/import is not always needed. |
Do you realise that variables can be over-ridden by definitions after they are used.. e.g. you could have one import right at the end.. does that simplify things? |
I know the current possibilities so I'll describe what I am doing with more details. We are using less to build skins which can be children of one another for a given product. A child can override its parent variables, mixins or styles directly, then a second level of customisation during the build is offered, when again, it's possible to override the skins variables, etc to adapt the product to the website where it will be. This, is also based on Twitter Bootstrap from which we import some of the less files. It is actually a nice way to rapidly create and deploy new variations and it's easy to fix something in the parent skin for the benefit of all the children. But, we don't need to import everything all the time. So it would be easier to just indicate an import as optional in our case. As SomMeri said, we could put empty less files everywhere but it would be a lot of useless files. |
I've added ready for implementation because it seems like it would be quite a simple addition to add and would have some benefit. If any of the core team disagree please feel free to substitute with NeedsDecision and add a comment. |
Hi, I'd like to discuss what would be the best syntax for this.
|
There's no choice in this case. All other import options are used like this: |
@seven-phases-max Thanks I'll check it. (although I see that your links points to 2.0.0 branch) |
Yep, because I suspect that (since v2 is coming and it would not be a good idea to come up with new-feature-v1.x-release) if you make a PR for this to the 1.x branch the efforts needed to move it to v2 later will overweight the efforts needed to code the feature itself (though @lukeapage will correct me if I'm wrong :) |
What's the current status on this feature? Is someone working on it? I've been looking for a way to import a .less file that will ignore the import if the specified file doesn't exist, but haven't been able to find a solution that doesn't include using conditional variables (which eliminates the purpose since I have to set the variable anyway and might as well just set the
|
@Villeman I said I would help but haven't done anything yet. I'm a bit overloaded with my own stuff. I don't think someone else is working on this. |
Hello,
This is a fairly simple option which I'd like to see in less.js.
It would look like this:
@import (optional) "filename";
or
@import-optional (reference) "filename";
(this way it can be combined to other import options)If less does not find the file marked as
optional
, it won't fail and just continue the compiling process.The use case is the following:
Less.js is part of a build process. (grunt based)
During this process, there are specific cases when we want to override the default styles. There are already variables than can be overridden for example.
When we want to override the variables, we need
If we don't do that, less will fail when
overridden-variables.less
is not there.It would be much easier to mark some files as optional that won't cause a problem if they are not present and this simplifies the build process.
What do you think?
Thanks for reading
The text was updated successfully, but these errors were encountered: