Skip to content

Instantly share code, notes, and snippets.

@fizerkhan
Forked from millermedeiros/build.xml
Created July 16, 2012 15:55
Show Gist options
  • Save fizerkhan/3123479 to your computer and use it in GitHub Desktop.
Save fizerkhan/3123479 to your computer and use it in GitHub Desktop.
RequireJS optimizer Ant task
<?xml version="1.0" encoding="utf-8"?>
<project name="sample-require-js" default="" basedir=".">
<!-- properties -->
<property name="r.js" value="_build/rjs/r.js" />
<property name="closure.jar" value="_build/closure/compiler.jar" />
<property name="rhino.jar" value="_build/rhino/js.jar" />
<property name="js.build" value="_build/js.build.js" />
<property name="css.build" value="_build/css.build.js" />
<!-- custom tasks -->
<!-- targets -->
<target name="-optimize" description="Combine and minify files.">
<java classname="org.mozilla.javascript.tools.shell.Main">
<classpath>
<pathelement location="${rhino.jar}" />
<pathelement location="${closure.jar}" />
</classpath>
<arg value="${r.js}"/>
<arg value="-o"/>
<arg value="${requirejs.optimizer.settings}"/>
</java>
<echo message="optimized ${requirejs.optimizer.settings}" />
</target>
<target name="optimizeJS">
<echo message="Combining and minifying JS files." />
<antcall target="-optimize">
<param name="requirejs.optimizer.settings" value="${js.build}" />
</antcall>
</target>
<target name="optimizeCSS">
<echo message="Combining and compressing CSS files." />
<antcall target="-optimize">
<param name="requirejs.optimizer.settings" value="${css.build}" />
</antcall>
</target>
</project>
({
baseUrl: "../style",
optimizeCss : "standard",
dir: "../../../deploy/style"
})
({
baseUrl: "../scripts",
dir: "../../../deploy/scripts",
modules: [
{
name: "main",
include : [
"lib/my_awesome_shared_lib"
]
},
{
name : "sections/home/main",
exclude : [
"lib/my_awesome_shared_lib"
]
},
{
name : "sections/gallery/main",
exclude : [
"lib/my_awesome_shared_lib"
]
}
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment