Coffee script compilation

前端 未结 11 2131
深忆病人
深忆病人 2020-12-13 05:19

I\'m looking for simplest possible way to automatically recompile coffee scripts into JS.

Reading documentation but still having troubles to get exactly what I want.

相关标签:
11条回答
  • 2020-12-13 05:40

    Being one level above /src, this will work for all .coffee files found no matter the depth.

    coffee -w -c src/
    
    0 讨论(0)
  • 2020-12-13 05:43
    find `pwd` | grep .coffee | xargs coffee -w -c
    

    try this one in root directory of the application

    0 讨论(0)
  • 2020-12-13 05:45

    Changed mind about concatenation.
    Created small compiler.sh file which contains:

    dnotify -M src/ -e coffee -o lib/ -c src/ &
    dnotify -M spec/ -e coffee -o lib/ -c spec/ &
    

    Kind a suits my needs.

    0 讨论(0)
  • 2020-12-13 05:47
    find -type f | grep .coffee | xargs ls -t | head -n 1 | xargs coffee -cw
    

    find last modifed coffee script and put it in compile-watch mode

    0 讨论(0)
  • 2020-12-13 05:47

    The short answer to your question is that the coffee utility wasn't designed for this; combining file-watching and concatenation is actually pretty complex. Expect more sophisticated build tools for CoffeeScript in the near future; until then, you might want to do your project's builds by writing a Cakefile or Ruby Watchr script. Then you can also throw in minification, documentation-generation, and whatever else you need for your particular project (not to mention guaranteeing a particular concatenation order).

    0 讨论(0)
  • 2020-12-13 05:48

    Well coffee --watch has 2 major flaws:

    • New files created after command has been issued aren't being watched
    • Requires manual initiation so there can be a chance you forget to do it, which doesn't sound more brilliant than forget to compile before you git commit it

    The solution I came up with is a rather simple Bash script that takes coffee --watch a few steps further which will allow your working directory tree to be watched ever since system login, and automatically get compiled into JavaScript on each file save/change or new file creation:

    http://blog.gantrithor.com/post/11609373640/carefree-coffeescript-auto-compiler

    There may be more elegant way to do this, but this implementation works great =)

    0 讨论(0)
提交回复
热议问题