Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenate JS files using ANT (keeping a specific order)

Tags:

javascript

ant

I have a bunch of js files that I need to concatenate in some specific order (becuase they are a part of an MVC implementation). How do I do this using ANT?

like image 765
Preslav Rachev Avatar asked Jan 29 '12 09:01

Preslav Rachev


2 Answers

<filelist id="filelist" dir="path/to/base/directory">
   <file name="util.js"/>
   <file name="commons.js" />
</filelist>

<target name="concat-all">
    <concat destfile="whatever" encoding="UTF-8" outputencoding="UTF-8" fixlastline="true">
        <filelist refid="filelist" />
    </concat>
</target>

We use this approach, and later resulting file is compressed via yui-compressor.

like image 148
Anton Avatar answered Nov 08 '22 12:11

Anton


With the concat task, using a filelist to preserve order.

like image 3
JB Nizet Avatar answered Nov 08 '22 12:11

JB Nizet