Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Trying to build LESS (less css) using a build script with nodeJS

Trying to build LESS (less css) using a build script with nodeJS

Problem

We are using Nodejs to build our project. We have integrated LESS CSS as a part of the project. We are attempting to keep our build clean and would like to be able to call the lessc command (or something comparable) in order to build our LESS files.

The LESS documentation isn't very in depth, but wanted to reach out to the community to find a Solution. Google has not be too helpful to me on this topic.

We have a build.sh file, that calls various other build.js files (in respective directories). How can I run LESSC to compile my LESS files?

Problem courtesy of: Bryan Kohlmeier

Solution

Using node.js

var less = require('less')
    ,fs = require('fs');

fs.readFile('style.less',function(error,data){
    data = data.toString();
    less.render(data, function (e, css) {
        fs.writeFile('style.css', css, function(err){
            console.log('done');
        });
    });
});
Solution courtesy of: Ripter

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Trying to build LESS (less css) using a build script with nodeJS

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×