Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 63 lines (44 sloc) 1.83 KB
#!/usr/bin/env bash
set -e
# Base directory for this entire project
BASEDIR=$(cd $(dirname $0) && pwd)
# Source directory for unbuilt code
SRCDIR="$BASEDIR/src"
# Directory containing dojo build utilities
TOOLSDIR="$SRCDIR/util/buildscripts"
# Destination directory for built code
DISTDIR="$BASEDIR/dist"
# Module ID of the main application package loader configuration
LOADERMID="app/run"
# Main application package loader configuration
LOADERCONF="$SRCDIR/$LOADERMID.js"
# Main application package build configuration
PROFILE="$BASEDIR/profiles/app.profile.js"
# Configuration over. Main application start up!
if [ ! -d "$TOOLSDIR" ]; then
echo "Can't find Dojo build tools -- did you initialise submodules? (git submodule update --init --recursive)"
exit 1
fi
echo "Building application with $PROFILE to $DISTDIR."
echo -n "Cleaning old files..."
rm -rf "$DISTDIR"
echo " Done"
cd "$TOOLSDIR"
if which node >/dev/null; then
node ../../dojo/dojo.js load=build --require "$LOADERCONF" --profile "$PROFILE" --releaseDir "$DISTDIR" $@
elif which java >/dev/null; then
java -Xms256m -Xmx256m -cp ../shrinksafe/js.jar:../closureCompiler/compiler.jar:../shrinksafe/shrinksafe.jar org.mozilla.javascript.tools.shell.Main ../../dojo/dojo.js baseUrl=../../dojo load=build --require "$LOADERCONF" --profile "$PROFILE" --releaseDir "$DISTDIR" $@
else
echo "Need node.js or Java to build!"
exit 1
fi
cd "$BASEDIR"
LOADERMID=${LOADERMID//\//\\\/}
# Copy & minify index.html to dist
cat "$SRCDIR/index.html" | tr '\n' ' ' | \
perl -pe "
s/<\!--.*?-->//g; # Strip comments
s/isDebug: *1/deps:['$LOADERMID']/; # Remove isDebug, add deps
s/<script src=\"$LOADERMID.*?\/script>//; # Remove script app/run
s/\s+/ /g; # Collapse white-space" > "$DISTDIR/index.html"
echo "Build complete"