Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile CoffeeScript on Save?

Is there anyway to easily compile CoffeeScript on save? I'm using TextMate or Sublime Text 2.

like image 506
fancy Avatar asked Jun 08 '11 23:06

fancy


People also ask

Is CoffeeScript still a thing?

As of today, January 2020, CoffeeScript is completely dead on the market (though the GitHub repository is still kind of alive).

Is CoffeeScript slower than JavaScript?

CoffeeScript tends to run as fast, or faster than hand-written JavaScript.


1 Answers

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.

like image 61
Elf Sternberg Avatar answered Sep 19 '22 15:09

Elf Sternberg