Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krasimir/less-compiler
Watch and compile your .less files automatically
https://github.com/krasimir/less-compiler
Last synced: 3 days ago
JSON representation
Watch and compile your .less files automatically
- Host: GitHub
- URL: https://github.com/krasimir/less-compiler
- Owner: krasimir
- Created: 2012-12-07T08:33:22.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2012-12-16T14:07:55.000Z (almost 12 years ago)
- Last Synced: 2024-11-07T11:06:34.326Z (6 days ago)
- Language: JavaScript
- Size: 164 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# less-compiler
The main purpose of the module is to compile your .less files automatically. It uses [watchr](https://npmjs.org/package/watchr) to monitor a specific folder for changes and [less](https://npmjs.org/package/less) for compilation. There are some other tools for the same purpose ([less-middleware](https://npmjs.org/package/less-middleware), [less-watch](https://npmjs.org/package/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](http://expressjs.com/).
## Requirements
[NodeJS](http://nodejs.org/)## 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.