Alex Rivera | Logout

How to use less.js with node.js to watch .less files in a folder?

Asked 2012-02-23T21:11:58.827
15

I am looking for a simple guide to setting up server-side watching and compiling .less files in a folder using less.js and node.js. Bryan wrote about it in this post.

Unfortunately, the instructions to Server-side usage on lesscss.org are of a little avail to somebody who is new to node.js.

I have tried command line usage: $ lessc styles.less > styles.css.

I have also tried 'watchr' and 'watch-less' and it all works. However, I am looking for a pure node.js + less.js solution. I am sure there is somebody who will be able to plainly explain how to configure node.js and less.js to watch .less files in a folder. Thanks.

Edit
Report

1 Answer

1

You can use supervisor with -e argument to provide extensions to watch:

nohup supervisor -e 'js|ejs|less' $APP_DIR/app.js  1>$APP_DIR/log/app.log 2>&1 &
echo $! > $APP_DIR/pid/app.pid;

Taken from node-startup script: https://github.com/chovy/node-startup

The simpler version of this command is:

supervisor -e 'js|ejs|less' app.js
answered 2012-11-09T07:03:00.433

Your Answer