modifyVars not being passed on
See original GitHub issueI have an index.less file that decides what variables file to load in by a variable like so:
@theme-variant: "a-theme.less";
@import "./@{theme-variant}";
I have less files that load in that index file:
@import "~theme-variant-variables";
I am setting a value for the variable in my webpack.config.js
file:
lessOptions.modifyVars = {
"theme-variant": `"${v}-theme.less"`
}
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?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
ModifyVars issue when trying to change variables one by one
I want to be able to modify each variable from my LESS file in the browser when a value is added in the...
Read more >Customize Theme
In ConfigProvider, we pass context through DesignTokenContext . When theme is undefined , a layer of Provider will not be set, so React...
Read more >Theming Ant Design: A Detailed Step by Step Guide
Ant Design styles rely on the CSS post-processor less. It's made clear that the correct way to theme Ant Design is to override...
Read more >LESS - Using Less In The Browser
useFileCache − Uses per session file cache. The cache in less files is used to call the modifyVars where all the less files...
Read more >How to use the customize-cra.addLessLoader function in ...
addLessLoader examples, based on popular ways it is used in public projects. ... Use Snyk Code to scan source code in minutes -...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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. Though any improvement ideas and especially PRs are always welcome… I don’t think anybody is going to get into this in a foreseeable future.
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:
@import "a-theme.less";
to be expicit there (i.e. w/o any interpolation) or remove it completely.modifyVars
set the importing statement itself (e.g.@import "custom-theme.less";
directly).Note that while
modifyVars
pretends it’s only about variables bla-bla-bla - in fact it does nothing but appending an arbitrary text to the end of the root file. I.e. in case oflessc
it’s realy just--modify-vars="whatever-less-code foo {bar: baz;}"
. I don’t know though what formats webpack’s less-loader can pass through, hmm…lessOptions.modifyVars = "an arbitrary code";
maybe?That’s obviously a hack but in fact it is quite predictable hack (as it abuses only
modifyVars
format and not the language itself like the initial combo does).