Add -w Watch mode to lessc command line tool. Closes cloudhead/less.js#192 #194

wants to merge 1 commit into


None yet
poswald commented Feb 8, 2011

As discussed in less/less.js#192

Call this with a command like:

$ lessc -w -x base.less base.css
8 Feb 17:26:10 - Change detected... Updated

One issue is that a parse error will cause the system to exit and you have to relaunch it. I also don't think it will watch imported stylesheets. Perhaps is there a better way to do this?

wvl commented Mar 29, 2011

Looks good -- you also want to process the file when you first launch. I made that change here:

Also, I pushed a bunch of changes that avoid the process.exit, so you do not have to relaunch the script on errors. I'll add a separate pull request for that change.

idris commented Jul 12, 2011

Any idea when this will be merged in? Maybe we can get a 1.1.4 release with this functionality?

idris commented Jul 13, 2011

I've made a lesswatch command that can be used to watch entire directories, rather than just watching one file. It just automatically compiles .less files into their .css counterparts, so you don't have to specify output files.

Try it out and let me know what you think


When developing, you can use watch-mode in the browser, by adding #!watch to the url, I don't want this as part of the command line tool.

@cloudhead cloudhead closed this Aug 22, 2011

This is essential to the command-line tool, why wouldn't you want it? It's the most reliable way to use LESS in a development environment and have an exported CSS always ready for deploy.

poswald commented Sep 2, 2011

I don't serve out the .less files directly to the browser so intentionally nerfing this feature of the command line tool seems a bit strange to me. I can understand wanting to keep a single way of doing things because it would be simpler but I don't think there would be a lot of confusion around this.

I added this as it was missing when I migrated from the original less project to the less.js project. Some of the styling work I do is with pages loaded into an embedded browser where I can't just append something to the url and we don't run javascript there anyway.

web-dev commented Nov 15, 2011

Cloudhead, could you elaborate on why you don't want this in the command line tool? It seems like the perfect place for this kind of functionality.

sjl commented Dec 5, 2011

I'd also like to know why? I use kicker to get around this on OS X but it makes working on Linux or Windows a pain in the ass.

yvess commented Dec 28, 2011

The watch command is also very important to me. This makes the use cases of lessc a lot more broader.
Everbody who migrates from sass or the less.js ruby version can keep their workflow.


There is a discussion on why here: #246 (comment)


As I mentioned in issue #192 — those still looking for a solution to this, I recommend Coyote

Coyote is a tool allowing you to watch source files for Coffescript, SASS, or LESS and then compile them on the fly. Example: coyote -w input.less:output.css

umrashrf commented Feb 6, 2014

Please add this life saver to command line!

Soviut commented Feb 6, 2014

@umrashrf As the other discussion says, there are already plenty of tools that do watching for multiple pre-compiled languages like LESS, CoffeeScript, Jade, etc. Look into Grunt or Gulp if you'd like to watch and build from the command line.


If anyone wants a new repo on less that is a watcher and then wants to help us refactor lessc to integrate with that watcher then they are more than welcome, but given grunt and gulp its not on my list of priorities.

Soviut commented Feb 9, 2014

Not only Grunt and Gulp, but the multitude of other GUI-based compilers with watchers as well. I think it's a duplication of effort and something others have done a better job solving already. Not to mention avoiding all the inevitable watcher-related issues that will clutter the issue tracker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment