合并目录中的javascript文件与节点uglify +手表?

目标:

我正在尝试为客户端模板开发构build一个毫不费力的工作stream程。

文件根目录:

/views/uncompiled/ /static/js/compiled/ 

我们从/views/uncompiled/

这是我可以build立东西的地方,比如/views/uncompiled/index.html

我构builddust.js模板,所以我使用dusterjs监听my /views/uncompiled/目录中的更改,并自动在我的/static/js/compiled/目录中呈现编译的*.js对应。

所以/views/uncompiled/index.html在保存更改时随时显示/static/js/compiled/index.js

问题:

我的layout.html越来越大。 每次添加另一个模板时,我需要包含一个新的*.js脚本:

 <head> <script src='/static/js/compiled/index.js'></script> <script src='/static/js/compiled/header.js'></script> <script src='/static/js/compiled/footer.js'></script> <script src='/static/js/compiled/baconstrips.js'></script> ... </head> 

解:

/static/js/compiled/文件夹中自动将concat *.js另一只手表放在一个app.js文件中,该文件夹的内容随时会被包含在<head>

 <head> <script src='/static/js/app.js'></script> </head> 

题:

我想使用像Uglify.js这样的concatonation工具也可以压缩。

  • 有没有任何节点包可以自动解决上述问题?
  • 有没有Uglify.js的本地函数已经这样做?

使用grunt.js 。 它有能力通过各种贡献模块观看/集中/缩小文件。 稍微习惯一下(我仍然是我自己),但是最终你会得到一个自定义的构build过程,这个过程就像想要的那样工作,这是无价的。