Preslav Rachev
Preslav Rachev

Reputation: 4003

Concatenate JS files using ANT (keeping a specific order)

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?

Upvotes: 8

Views: 4696

Answers (2)

Anton
Anton

Reputation: 6051

<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.

Upvotes: 16

JB Nizet
JB Nizet

Reputation: 691655

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

Upvotes: 3

Related Questions