Coffee script compilation

2019-01-21 14:22发布

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.

I need it to watch folder src/ for any *.coffee files modifications and compile them into concatenated javascript file into lib/something.js.

Somehow can't combine watching, compiling and concatenating together. :/

11条回答
Fickle 薄情
2楼-- · 2019-01-21 14:36

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.

查看更多
放荡不羁爱自由
3楼-- · 2019-01-21 14:37
find `pwd` | grep .coffee | xargs coffee -w -c

try this one in root directory of the application

查看更多
神经病院院长
4楼-- · 2019-01-21 14:38

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 =)

查看更多
放荡不羁爱自由
5楼-- · 2019-01-21 14: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

查看更多
乱世女痞
6楼-- · 2019-01-21 14:49

nodemon -x coffee server.coffee does it for me.

Install nodemon using npm install -g nodemon

查看更多
登录 后发表回答