-
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
modifyVars not being passed on #3179
Comments
I suppose this is the same thing as in #2772 - see the middle of discussion there (e..g. In short the point is: variable interpolation within import statements is a handy thing but it directly conflicts with lazy-evaluation principle. Thus if it comes to complex structuring, one would better find other ways to achieve such kind of customization (e.g. using different dirs for different theme files and then setting corresponding |
Thanks for the reply. The variable is updated in less files that are directly imported by JS, it's just files that are imported by other less files that don't have their variable updated. Lazy evaluation is occurring in both cases surely? It looks like the modify var logic/config isn't being applied/passed on to the less imported files. Or am I missing something? |
Well, it's more tricky than that. Notice that for the lazy-evaluation to work the compiler has to evaluate various language entities (in the same scope) by types not by the order they appear in code, from higher level to lower, i.e. (roughly): imports -> mixins -> variables. There's no way for the compiler to guarantee any consistent behaviour when two directly conflicting features are combined. In other words, it's not that And even if the docs say:
... it's not really much better after v2. It did improve/kludge-fix more combinations/use-cases but can't fix all of them. For more details see #1108 and specifically #2246.
No (simply because in the end the files are evaluated all together as a single large string). Unless the problem is elsewhere, to check simply add: |
By the way. For your use-case (if the "*-theme.less" is only about variables/mixins for a specific theme), you could try something like:
Note that while That's obviously a hack but in fact it is quite predictable hack (as it abuses only |
Thank you very much for your replies and ideas @seven-phases-max I'm going to investigate further during the week and have set a reminder to update/close this issue later on in the week. Thanks again. |
I'll close this then as it's more like an expected (defined as "undefined/unspecified" in this case) behaviour rather than an issue that could be actually fixed somehow. |
I have an index.less file that decides what variables file to load in by a variable like so:
I have less files that load in that index file:
I am setting a value for the variable in my
webpack.config.js
file:If I move the contents of the index.less file into a directly imported less file everything works as I expect, I can switch the variables file chosen based on the webpack config logic, sadly if I try and centralize those two lines of less into a file that the directly imported less files import themselves it stops working. I see less loader calls less with the expected config so I'm guessing the less compiler doesn't propagate variables/options to imported less files. Is that expected?
The text was updated successfully, but these errors were encountered: