Skip to content

Commit b82be02

Browse files
committed
build: improve minification, more verbose
1 parent 84a6764 commit b82be02

5 files changed

Lines changed: 49 additions & 21 deletions

File tree

build.xml

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="ISO-8859-1"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<project name="html2canvas" basedir="." default="build">
33
<property name="src.dir" location="src"/>
44
<property name="lib.dir" location="../lib"/>
@@ -11,44 +11,56 @@
1111
<property name="JQUERY_PLUGIN_NAME" value="jquery.plugin.html2canvas.js"/>
1212
<loadfile property="version" srcfile="version.txt" />
1313

14-
<fileset id="sourcefiles" dir="${src.dir}">
15-
<include name="LICENSE"/>
16-
<include name="Core.js"/>
17-
<include name="Generate.js"/>
18-
<include name="Parse.js"/>
19-
<include name="Preload.js"/>
20-
<include name="Queue.js"/>
21-
<include name="Renderer.js"/>
22-
</fileset>
14+
<path id="sourcefiles">
15+
<filelist dir="${src.dir}">
16+
<file name="LICENSE"/>
17+
<file name="html2canvas-pre.txt"/>
18+
<file name="Core.js"/>
19+
<file name="Generate.js"/>
20+
<file name="Parse.js"/>
21+
<file name="Preload.js"/>
22+
<file name="Queue.js"/>
23+
<file name="Renderer.js"/>
24+
<file name="Util.js"/>
25+
<file name="html2canvas-post.txt"/>
26+
</filelist>
27+
</path>
2328

2429
<path id="jquery-plugin">
2530
<fileset dir="${src.dir}" includes="LICENSE"/>
26-
<fileset dir="${src.dir}/plugins" includes="${JQUERY_PLUGIN_NAME}"/>
31+
<fileset dir="${src.dir}/plugins" includes="${JQUERY_PLUGIN_NAME}"/>
2732
</path>
2833

29-
<target name="plugins">
34+
<target name="build-dir">
35+
<echo>Creating directory ${build.dir}...</echo>
36+
<mkdir dir="${build.dir}"/>
37+
</target>
38+
39+
<target name="plugins" depends="build-dir">
40+
<echo>Creating ${JQUERY_PLUGIN_NAME}...</echo>
3041
<concat fixlastline="yes" destfile="${build.dir}/${JQUERY_PLUGIN_NAME}">
3142
<path refid="jquery-plugin"/>
3243
</concat>
3344
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JQUERY_PLUGIN_NAME}" />
3445
</target>
3546

47+
<pathconvert property="prettty-sourcefiles" pathsep="${line.separator}" refid="sourcefiles"></pathconvert>
3648

37-
<target name="build" depends="plugins">
49+
<target name="build" depends="build-dir,plugins">
50+
<echo>Concatenating files:${line.separator}${prettty-sourcefiles}${line.separator}into ${build.dir}/${JS_NAME}...</echo>
3851
<concat fixlastline="yes" destfile="${build.dir}/${JS_NAME}">
39-
<fileset refid="sourcefiles"/>
52+
<path refid="sourcefiles"/>
4053
</concat>
4154
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JS_NAME}" />
4255
</target>
4356

44-
4557
<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask"
4658
classpath="${lib.dir}/compiler.jar" onerror="report"/>
4759

48-
<target name="release" depends="build">
60+
<target name="syntaxcheck" depends="build-dir,build">
4961
<jscomp compilationLevel="simple" warning="verbose"
5062
debug="false"
51-
output="${build.dir}/${JS_NAME_MIN}">
63+
output="${build.dir}/${JS_NAME_MIN}.tmp">
5264
<externs dir="${lib.dir}">
5365
<file name="${jquery-externs}"/>
5466
</externs>
@@ -61,15 +73,28 @@
6173
<file name="Preload.js"/>
6274
<file name="Queue.js"/>
6375
<file name="Renderer.js"/>
76+
<file name="Util.js"/>
77+
</sources>
78+
</jscomp>
79+
<delete file="${build.dir}/${JS_NAME_MIN}.tmp"></delete>
80+
</target>
81+
82+
<target name="release" depends="build-dir,build,syntaxcheck">
83+
<jscomp compilationLevel="simple" warning="verbose"
84+
debug="false"
85+
output="${build.dir}/${JS_NAME_MIN}">
86+
<externs dir="${lib.dir}">
87+
<file name="${jquery-externs}"/>
88+
</externs>
89+
<sources dir="${build.dir}">
90+
<file name="${JS_NAME}"/>
6491
</sources>
6592
</jscomp>
6693
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JS_NAME_MIN}" />
6794
</target>
6895

6996
<target name="clean">
70-
<delete file="${build.dir}/${JS_NAME}"></delete>
71-
<delete file="${build.dir}/${JS_NAME_MIN}"></delete>
72-
<delete file="${build.dir}/${JQUERY_PLUGIN_NAME}"></delete>
97+
<delete dir="${build.dir}"></delete>
7398
</target>
7499
</project>
75100

build/.gitkeepdir

Whitespace-only changes.

src/html2canvas-post.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
window.html2canvas = html2canvas;
2+
}(window, document));

src/html2canvas-pre.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(function(window, document, undefined){

tests/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
(function(document, window) {
99
var scrStart = '<script type="text/javascript" src="', scrEnd = '"></script>';
1010
document.write(scrStart + '../external/jquery-1.6.2.js' + scrEnd);
11-
var html2canvas = ['Core', 'Generate', 'Parse', 'Preload', 'Queue', 'Renderer', 'plugins/jquery.plugin.html2canvas'], i;
11+
var html2canvas = ['Core', 'Generate', 'Parse', 'Preload', 'Queue', 'Renderer', 'Util', 'plugins/jquery.plugin.html2canvas'], i;
1212
for (i = 0; i < html2canvas.length; ++i) {
1313
document.write(scrStart + '../src/' + html2canvas[i] + '.js' + scrEnd);
1414
}

0 commit comments

Comments
 (0)