Here's how you can convert your LESS stylesheet to precompiled CSS stylesheet using nodeJS:
npm install -g less
Open a new terminal in your favorite code editor, for example Visual Studio Code and run the command below
npm install -g less
Let's take for example the LESS string below:
@font-color:blue;
@link-color:@font-color;
h1{
color: @font-color
}
a{
color: @link-color
}
You want to compile this LESS string to CSS using NodeJS, you can do it like so:
const less = require('less');
module.exports = async function (context, req) {
less.render([YOUR LESS STRING], null)
.then(function(output) {
output.css; // CSS output
},
function(error) {
context.res = {
body: error
};
});
}
Replace [YOUR LESS STRING] with any LESS input, the output will be returned from the "css" property that the render function returns (output.css)
The following content will be generated from the "output.css" variable:
h1 {
color: blue;
}
a {
color: blue;
}
You can also use the tool in this page to precompile your LESS input into CSS format. Just copy paste you LESS input in the first code editor, click on convert and voila your CSS string will be displayed in the right editor.