-
Notifications
You must be signed in to change notification settings - Fork 7
/
build-viewer.sh
51 lines (36 loc) · 1.36 KB
/
build-viewer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/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/dojo/viewer"
# Main application package build configuration
PROFILE="$BASEDIR/build.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
if [ ! -d node_modules ]; then
echo "Can't find Node.js dependencies -- did you install them? (npm install)"
exit 1
fi
echo "Building application with $PROFILE to $DISTDIR."
echo -n "Cleaning old files..."
rm -rf "$DISTDIR"
echo " Done"
#node_modules/.bin/stylus -c "$SRCDIR/app/resources/app.styl"
"$TOOLSDIR/build.sh" --profile "$PROFILE" --releaseDir "$DISTDIR" $@
cd "$BASEDIR"
# Copy & minify index.html to dist
cat "$SRCDIR/index.html" | \
perl -pe 's/\/\/.*$//gm; # Strip JS comments' |
perl -pe 's/\n/ /g; # Replace newlines with whitespace' |
perl -pe 's/<\!--.*?-->//g; # Strip HTML comments' |
perl -pe 's/isDebug: *true,//; # Remove isDebug' |
perl -pe 's/\s+/ /g; # Collapse whitespace' > "$DISTDIR/index.html"
echo "Build complete"