Skip to content

Instantly share code, notes, and snippets.

@Sjeiti
Sjeiti / getLessVars.js
Last active September 22, 2020 04:51
function to parse LESS variables to Javascript
/**
* getLessVars parses your LESS variables to Javascript (provided you make a dummy node in LESS)
* @param {String} id The CSS-id your variables are listed under.
* @param {Boolean} [parseNumbers=true] Try to parse units as numbers.
* @return {Object} A value object containing your LESS variables.
* @example
* LESS:
* @myLessVariable: 123px;
* #dummyLessId { width: @myLessVariable; }
* Javascript: