问题描述
我有一堆我分割的JS文件,但想自动连接(所以我没有定义HTML中的一堆文件)。现在,我复制了Twitter Bootstrap的命令。 Makefile:
脚本:
猫脚本/ *。js> public / scripts / scripts.js
watchScripts:
watchr -ewatch('scripts /.* \.js'){system'make scripts'}
但是,我发现 watchr
非常不一致(在Mac OS X 10.8上)
- 有时当我保存
js
文件时,它不运行make scripts
。其他时候,它的确如此。 - 有一次,它在一次保存后不断运行
make scripts
。 - 有时,它会在最后一次保存后几秒钟运行该命令。我
我做错了什么?我正在使用 node.js
而不是 Ruby
,所以有没有节点。 js
命令行选项?当我在Bootstrap中尝试 make watch
时,同样的问题似乎发生在我身上。
stylus -w -u nib styles / styles.styl -o public / styles
如何在单个Makefile命令中运行两个watch命令? IE make watch
将同时观看 .styl
文件进行编译, .js
文件进行连接。现在,我打开了两个终端,每个监视命令,但我更喜欢一个。
有你尝试过?在node.js上工作时,这对于这类东西来说真的很棒。您可以使用一个框架或手动设置它,并为您的整个目录创建一个脚本,在旅途中进行合并和编译。
I have a bunch of JS files that I split up, but want to concatenate automatically (so I don't define a bunch of files in HTML). Right now, I copied the command from Twitter Bootstrap. Makefile:
scripts:
cat scripts/*.js > public/scripts/scripts.js
watchScripts:
watchr -e "watch('scripts/.*\.js') {system 'make scripts'}"
However, I've found watchr
to be very inconsistent (on Mac OS X 10.8)
- Sometimes when I save a
js
file, it doesn't runmake scripts
. Other times, it does. - One time, it just kept running
make scripts
continuously after a single save. - Sometimes, it will run the command a few seconds after the last save.
Am I doing something wrong? I'm working using node.js
and not Ruby
, so are there any node.js
command-line alternatives? The same issues seem to happen to me when I try make watch
in Bootstrap.
Aside question: I have another watch command:
stylus -w -u nib styles/styles.styl -o public/styles
How can I run two watch commands in a single Makefile command? IE make watch
will watch both .styl
files to compile, and .js
files to concatenate. Right now I'm opening up two terminals, for each watch command, but I'd prefer a single one.
Have you tried brunch? It's really great for this kind of stuff when working on node.js. You can just use a skeleton or set it up manually and have a script your whole directory, merging and compiling on the go.
这篇关于使用Watchr自动连接文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!