Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added uglifyjs task

  • Loading branch information...
commit 7901cdfff0802ba911f10e2335149bace425d332 1 parent 7f0e547
@nzakas authored
Showing with 54 additions and 0 deletions.
  1. +54 −0 macros/uglifyjs.xml
View
54 macros/uglifyjs.xml
@@ -0,0 +1,54 @@
+<project name="uglifyjs">
+
+ <!-- macro to minify files -->
+ <macrodef name="uglifyjs">
+
+ <attribute name="outputdir"/>
+
+ <attribute name="beautify" default="" />
+ <attribute name="no-mangle" default="" />
+ <attribute name="no-mangle-functions" default="" />
+ <attribute name="no-dead-code" default="" />
+ <attribute name="failonerror" default="true" />
+ <element name="files" implicit="true"/>
+
+ <sequential>
+ <echo>Minifying with UglifyJS</echo>
+ <script language="javascript"><![CDATA[
+ var beautify = "@{beautify}",
+ noMangle = "@{no-mangle}",
+ noMangleFuncs = "@{no-mangle-functions}",
+ noDeadCode = "@{no-dead-code}",
+ options = "";
+
+ if (noMangle == "true") {
+ options += " --no-mangle";
+ }
+
+ if (noMangleFuncs == "true") {
+ options += " --no-mangle-functions";
+ }
+
+ if (noDeadCode == "true") {
+ options += " --no-dead-code";
+ }
+
+ project.setProperty("buildr.uglifyjs.options", options);
+
+ ]]></script>
+ <echo>Using: ${buildr.uglifyjs.options}</echo>
+ <apply executable="uglifyjs" failonerror="@{failonerror}">
+ <files/>
+ <mapper type="regexp" from="^(.*?)\.js$$" to="@{outputdir}/\1-min.js"/>
+
+ <arg line="${buildr.uglifyjs.options}"/>
+
+ <arg line="-o"/>
+ <targetfile/>
+
+ <srcfile/>
+
+ </apply>
+ </sequential>
+ </macrodef>
+</project>
Please sign in to comment.
Something went wrong with that request. Please try again.