[英]Concatenating JavaScript files using Ant
I have about 50-60 js files and there are dependencies among them so I need to maintain an order while cocatenating. 我有大约50-60个js文件,并且它们之间存在依赖关系,所以我需要在cocatenating时维护一个订单。 Writing all the names in "files" attribute would make the build.xml messy and any addition of js files in future would need to added accordingly.
在“files”属性中写入所有名称会使build.xml变得混乱,并且将来需要添加任何js文件。 So, I wanted to write the order in a separate txt file and just copy the contents using Ant following that order.
所以,我想在一个单独的txt文件中编写订单,然后按照该顺序使用Ant复制内容。 Is it possible ?
可能吗 ?
You can do what you want using a resourcelist
, for example: 您可以使用
resourcelist
,例如:
<concat destfile="concatenated.js">
<resourcelist>
<file file="js.files.txt"/>
<filterchain>
<striplinecomments>
<comment value="#"/>
</striplinecomments>
</filterchain>
</resourcelist>
</concat>
The filterchain
isn't required, but is useful as you can then include comment lines in your list-of-files. filterchain
不是必需的,但是很有用,因为您可以在文件列表中包含注释行。
You can use order independent declarations like these: 您可以使用以下与订单无关的声明:
// in every file
if(!("myLib" in window))myLib = {};
if(!("canvas" in myLib))myLib.canvas = { .... };
//next file
if(!("myLib" in window))myLib = {};
myLib = $.extend(myLib, true, {
init: function(){},
move: function(){}
});
//in index
myLib.init();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.