Compile CoffeeScript on Save?

Coffeescript has a ‘watch’ feature. You could set up, as a semi-permanent process:

coffee –wc -o media/js/ src/coffee/*.coffee

And for every file with an extension “.coffee”, the corresponding compiled “.js” file will be put into the target directory every time you save.

That said, I use a makefile and a fabfile, because my HTML is HAML, my CSS is LessCSS, and my development directory is not my test path, so I needed something smart enough to “build and deploy.”

If your machine supports inotify, you could use inotifywait to watch your entire work path, and call Make as needed. But at that point, you’re into hard-core geekery.

Leave a Comment