27Mar

How to get the Ruby ‘lessc -w’ option under Node for LessCss

Posted by Elf Sternberg as Linux, programming

If you’re one of those early adopters of LessCss, then you probably know by now that development of the original Ruby version has been abandoned in favor of a version that runs under Node.js. I’m a big fan of LessCss; both the nested definitions and parametric definitions make my life a whole lot easier.

I installed the latest version today and noticed that it’s missing a feature I really liked in the Ruby edition: the “watch” feature. This would allow you to edit your LessCss source document, and would automagically re-run the compiler to produce valid CSS. You wouldn’t have to run it by hand to tweak your document. The Node.js version of LessCss doesn’t have this feature.

It’s possible to get the same effect, however, if you’re running a system that uses inotify. If you have inotify in your kernel, install inotify tools, and you’ll have the program inotifywait, which is a useful tool for the command line that waits until a file changes, and then allows your script to proceed.

In bash, the code is:

while true; do inotifywait style.less ; lessc style.less style.css ; done

That’s it. Now, every time you save your LessCss file, the css equivalent will be automatically generated.

1 Response to How to get the Ruby ‘lessc -w’ option under Node for LessCss

Rummy Song

September 27th, 2011 at 4:21 am

This is a great help to anyone who are lost in the language of web design and web programming and more. Simple, direct to the point and very friendly to its visitors. Everything is well organize so you wont have to break your head out every time you are trying to find something useful and important for your projects…perfect 10

Comment Form

Subscribe to Feed

Categories

Calendar

March 2011
M T W T F S S
« Feb   Apr »
 123456
78910111213
14151617181920
21222324252627
28293031