summaryrefslogtreecommitdiff
path: root/build.ant
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-02-17 12:52:24 +0200
committerAlon Levy <alon@pobox.com>2015-02-17 12:52:37 +0200
commitedf91a5ab2a6afa88999403af5b11b722bb0b378 (patch)
tree9b4a24506fc1b5ddf04b172948d165d02bca6f5a /build.ant
parent72c0463055f534c642a57b35ab17ec6c1d6c89a5 (diff)
client/server: support optimizing with require.js using node run r.js
built is controlled by property do-client-optimize which defaults to false. Even if the optimized main is built (single file main-built.js and source map file main-built.js.map) they are not used unless rhizi-config.conf client_optimize is set to True which causes app.js to use main-built.js and not main.js The resulting file is 687 KiloBytes large. Pretty scary, but it still loads faster this way. (from very small tests locally). This is without compression done by the server.
Diffstat (limited to 'build.ant')
-rw-r--r--build.ant17
1 files changed, 16 insertions, 1 deletions
diff --git a/build.ant b/build.ant
index 2c2b9595..8b4a522a 100644
--- a/build.ant
+++ b/build.ant
@@ -3,7 +3,7 @@
Rhizi build targets
-->
-<project name="rhizi-server" default="pkg-deb">
+<project name="rhizi-server" default="pkg-deb" xmlns:if="ant:if">
<macrodef name="rsync">
<attribute name="src" />
@@ -22,12 +22,23 @@
</sequential>
</macrodef>
+ <macrodef name="client-optimize">
+ <attribute name="root" />
+ <attribute name="build" />
+ <sequential>
+ <exec dir="@{root}" executable="/usr/bin/r.js" failonerror="true">
+ <arg line="-o @{build}" />
+ </exec>
+ </sequential>
+ </macrodef>
+
<property name="pkg_name" value="rhizi-server" />
<property name="pkg_version" value="0.1.0" />
<property name="buildDir" value="build/${pkg_name}-${pkg_version}" />
<property name="targetDeploymentDir" value="deploy-local" />
<property name="remoteDeployServer" value="rhizi.net" />
<property name="targetDomain" value="rhizi.net" />
+ <property name="do-client-optimize" value="false" />
<tstamp>
<format property="versionQualifier" pattern="yyyyMMddHHmm" />
@@ -69,6 +80,8 @@
<copy file="res/etc/rhizi-server.conf.example"
tofile="res/etc/rhizi-server.conf" />
+ <client-optimize if:true="${do-client-optimize}" root="src/client/" build="build.js" />
+
<parallel>
<rsync src="${src_client}/" dst="${targetDeploymentDir}/static" />
<rsync src="res/client/" dst="${targetDeploymentDir}/static" />
@@ -93,6 +106,8 @@
<property name="filter_list_str"
value="-f '- __pycache__/' -f '- *.pyc'" />
+ <client-optimize if:true="${do-client-optimize}" root="src/client/" build="build.js" />
+
<!-- -l: traverse bin/ -> ../src-py link -->
<rsync src="${targetDeploymentDir}/"
extraopts="-lL --delete ${filter_list_str}"