在保存时编译 CoffeeScript?

2022-01-24 00:00:00 node.js javascript textmate coffeescript

是否有在保存时轻松编译 CoffeeScript 的方法?我正在使用 TextMate 或 Sublime Text 2.

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

推荐答案

Coffeescript 具有观看"功能.您可以将其设置为半永久性流程:

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

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

并且对于每个扩展名为.coffee"的文件,每次保存时都会将对应的编译后的.js"文件放入目标目录中.

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

也就是说,我使用 makefile 和 fabfile,因为我的 HTML 是 HAML,我的 CSS 是 LessCSS,我的开发目录不是我的测试路径,所以我需要足够聪明的东西来构建和部署".

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."

如果您的机器支持 inotify,您可以使用 inotifywait 来查看您的整个工作路径,并根据需要调用 Make.但到那时,你就陷入了顽固的极客中.

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.

相关文章