Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make less variables accessible from javascript?

Tags:

I have a less file colours which defines looks like the following:

@black:                 #000;
@greyDarker:            #222;
...etc

And want to be able to access these from within javascript, so for example:

$('body').style('color', 'window.colours.black') // or however I assign them

would work.

Since Less is getting compiled server-side the usual options wouldn't work.

I've started going ahead and writing a grunt task to generate a js file from these less rules however this seems like an inefficient / hacky way to go about it.

Any suggestions on a better approach or tools that could help