-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample_build.sh
executable file
·51 lines (36 loc) · 1.36 KB
/
sample_build.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"
# 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
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"