Dirk Bergmann

Developer, panographer. Does consultancy work from own company. Lives in Chiang Mai, Thailand.

Twitter

Chiang Mai

Hua Hin

Thailand Hotels

ListVote - List. Vote. Learn.

Partnerseek - Find Partners

LessCss / Less.js With --watch Option Watching Included Files

Needed a less css compiler who watches changes to a main .less file as well as all those include with an @import statement.

##

One could just use an old version of the less gem that still supported the ?watch option, i.e. the 1.x versions. However, the gem won't track included/imported files, the obsolete more plugin was required for this in Ruby on Rails. Peeking over the platform wall, the dotless compiler does all this well under Windows and it's very fast. However, running this app with mono on Linux will not work with the ?watch option, it will stop watching files after all and any file changes. This may be due to different backends of the mono FileSystemWatcher implementation on different Linux platforms, so YMMV. Meanwhile, the author of less.js has declined to support the ?watch option and has rejected at least one merge request with this functionality.

##

Alas,  there's a fork that supports watching the main file as well as all includes:

https://github.com/wvl/less.js

It works great and is stable. All you have to do is clone the repo and add bin/lessc to your path. Now with a node installation (since recently there is a Windows installer) you should be good to go with silent and effortless server side compilation of less on all platforms.