Access global variable in .less file

I have a global variable initialised using inject method in application-init file.I used inject method to inject in mixin,service,controller,component.Please suggest me how to inject the varible in .less files ? I have vendor directory with some files in it .I want to acees the varibale in those files also.

Depending on what browsers you’re targeting, and how the value is being used in JavaScript, a CSS variable might be a good choice. These are different from Less variables but can be read by both CSS and JavaScript

In the application initialisation the variable could be read or set depending on if the value should be stored in Less or in JavaScript to start with

An alternate approach is to write the value into Less at build time. There might be an add on which does this for you but I couldn’t find one

1 Like