Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to console log a LESS variable during compile?

I'm doing some debugging of a very complex parent / child theme system with Bootstrap and LESS CSS. I won't get into the details of that issue, except to say that I'm declaring custom colors and other variables in variables.less but the compiled CSS is not using these variables, however, I've verified that the file is actually being compiled and successfully included.

So, what I really need is to be able to somehow console.log the LESS variables (specifically at compile runtime), but despite the fact that LESS claims to support javascript inside of LESS files, that wasn't working. Can anyone shed light on this / have experience with it?

like image 718
Brian Avatar asked Feb 23 '13 22:02

Brian


People also ask

Why we should not use console log?

It often happens that console. log are forgotten in several places in the code, which besides a hypothetical loss of performance (tiny, but whose size varies according to the data called through the log method), is not very clean. The solution is to use the debugging tools provided by your browser.

Does console log slow down performance?

Using console. log will use CPU cycles. In computing, nothing is "free." The more you log, the slower your code will execute.

Can we store console log in a variable?

If you want to do this to an object that has been already logged (one time thing), chrome console offers a good solution. Hover over the printed object in the console, right click, then click on "Store as Global Variable". Chrome will assign it to a temporary var name for you which you can use in the console.


1 Answers

but despite the fact that LESS claims to support javascript inside of LESS files, that wasn't working.

It is:

@var: value;

.test {
    width: ~`console.log("@{var}"), "@{var}"`;
}
like image 159
seven-phases-max Avatar answered Nov 02 '22 22:11

seven-phases-max