Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including lesscompile with all npm packages installed. Try it out:

var lesscompile = require("lesscompile")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

lesscompile v0.0.6

compilation of project's less

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.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free