Change one variable with less.js

I am trying to use less.js to make changes to a smaller stylesheet for demo purposes. I would like this to be done, it is to remember the previous changes, so I need to send only one change for efficiency. Say I have the following:

@PrimaryColor: #FFF; @SecondaryColor: #000; 

If I change one parameter, it works fine.

 less.modifyVars({ "@PrimaryColor": "#ff0000" }); 

Now the colors are as follows:

 @PrimaryColor: #ff0000; @SecondaryColor: #000; 

Now, if I call the method again:

 less.modifyVars({ "@SecondaryColor": "#00ff00" }); 

The primary color switches back and the secondary color changes:

 @PrimaryColor: #FFF; @SecondaryColor: #00ff00; 

My question is, is there a method or method that will simply change one parameter and leave the other changes alone?

0
javascript css less
source share
1 answer

A quick look at the source code in the modifyVars file confirms that you cannot do this.

It seems that the .less source file .less recompiled every time you call modifyVars , and only those changes that you passed in the last call to modifyVars .

+1
source share

All Articles