is there a coffeescript auto compile / file watcher for windows?

放肆的年华 提交于 2019-12-13 11:57:08

问题


I'd like to play around with integrating coffeescript into my dev process. But as I see it, I'll have to make a bat file that iterates a set of coffee files and spits out js files. Every time I write a bat file, useful as they may be, I ask myself: is there a better way?

Which makes me wonder: is there an app of some sort for Windows that will watch a directory or a file and spit out one/many js files when a coffee file is saved? I'm thinking of building one but don't want to reinvent the wheel. I looked around and found things that were similar but nothing that elevated it beyond "run this command line" on Windows.

Edit: already marked an answer, but looking at this 10 months later the answer is: grunt. Because it'll do a lot more than just auto-compile your coffeescript and you'll probably need to do more than just that to get your app going.


回答1:


coffee --watch -o lib -c src

where src is a directory containing your coffee files, and lib is your JavaScript output directory.




回答2:


See update at bottom of post.

I was hunting for the same thing the other day and came across this: https://github.com/danenania/CoffeePy

It's a simple python script that uses PyV8 to run coffee-script.js.

It doesn't do anything fancy, just watches a folder recursively, and compiles any .coffee files whenever they're changed. It doesn't even have a bare option. These things could be very easily added though!

Edit:

I forked the script and added --bare and --output options.

You can get it here: https://github.com/johtso/CoffeePy




回答3:


Personally, I prefer using build tools like grunt.js / yeoman or brunch for that purpose.

grunt.js & grunt coffee




回答4:


Mindscape Workbench has a built in compiler/editor for VS 2010. Haven't tried it yet, but it looks like it'd be even better than a watcher/compiler. Scott Hanselman has a post about it here:

http://www.hanselman.com/blog/CoffeeScriptSassAndLESSSupportForVisualStudioAndASPNETWithTheMindscapeWebWorkbench.aspx




回答5:


I think there is a simplier way just using -w option of coffeescript compiler

coffee -c -w *.coffee

This will compile all coffee files under the folder you are (put more file pathes if needed) each time you change one.




回答6:


Another possibility: WebStorm 6. They've added a built in file-watcher for a variety of next-gen languages like SASS and Coffescript.




回答7:


If you want a different way of doing it, this might help: http://jashkenas.github.com/coffee-script/#scripts

If you include the coffeescript compiler on your page, you can include files with a "text/coffeescript" type and they will get compiled client-side.

Word of warning: Obviously, client-side compilation is not for something serious, but its completely fine for a small project/quick development. It would then be trivial to compile them on the server and change the MIME-type and filename when something a bit quicker is necessary.




回答8:


CoffeeScript-dotnet does what you want, but it is a command line tool.

Command line tool for compiling CoffeeScript. Includes a file system watcher to automatically recompile CoffeeScripts when they change. Roughly equivalent to the coffee-script node package for linux / mac.




回答9:


Here is the best way to do it: Say your work is in "my-project-path" folder.

  1. Go to the parent folder of "my-project-path"
  2. Start a terminal and type coffee -o my-project-path -cw my-project-path

This line will watch and compile anything name as "*.coffee" in "my-project-path" folder, even if it is in "my-project-path/scripts/core" or "my-project-path/test/core".The js file will locate in the save folder as the .coffee file.



来源:https://stackoverflow.com/questions/6564928/is-there-a-coffeescript-auto-compile-file-watcher-for-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!