lesscompile

compilation of project's less

npm install lesscompile
16 downloads in the last week
43 downloads in the last month

less-compiler

The main purpose of the module is to compile your .less files automatically. It uses watchr to monitor a specific folder for changes and less for compilation. There are some other tools for the same purpose (less-middleware, less-watch) out there, but I needed completelly node based thingy - without the usage of the command line. I.e. something that I could add in my node project without the usage of express.

Requirements

NodeJS

Installation

npm install lesscompile

Usage

require("lesscompile").init({
    pathToWatch: [path to your less files],
    fileToCompile: [your main less file],
    destination: [.css file as a destination],
    watchForChanges: [true or false, true by default]
});

example:

require("lesscompile").init({
    pathToWatch: __dirname + "/less",
    fileToCompile: __dirname + "/less/main.less",
    destination: __dirname + "/compiled/styles.css",
    watchForChanges: true
});

or with callback:

require("lesscompile").init({
    pathToWatch: __dirname + "/less",
    fileToCompile: __dirname + "/less/main.less",
    destination: __dirname + "/compiled/styles.css"
}).onCompile(function(css) {
    console.log("the compiled css: ", css);
});

If you need to know when the compiler started to watch:

require("lesscompile").init({
    pathToWatch: __dirname + "/less",
    fileToCompile: __dirname + "/less/main.less",
    destination: __dirname + "/compiled/styles.css"
}).ready(function() {
    console.log("I'm ready ...");
});

The usage of absolute paths is recommended.

npm loves you