-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.sh
executable file
·71 lines (58 loc) · 1.63 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
function bundle {
node ./node_modules/browserify/bin/cmd.js -t sassify2 -t es6ify $1 |
( [[ "$DEBUG" ]] && cat || ./node_modules/uglify-js/bin/uglifyjs -m -c ) |
cat > $2
}
DEBUG=
FILE=
OTHERARGS=
while getopts "vhdf:" flag
do
case "$flag" in
f) FILE=$OPTARG ;;
d) DEBUG=true;;
esac
# echo "$flag" $OPTIND $OPTARG
done
if [ -z $FILE ]; then
shift $((OPTIND-1))
OTHERARGS="$@"
fi
printf 'building'
printf 'test bundle\n\n';
# the test bundle
bundle ./test/main.js ./public/mocha/tests.js
printf '.'
printf 'mraid bundle\n\n';
# the mraid.js polyfill
mkdir -p ./dist
bundle ./src/polyfill/main.js ./dist/mraid.js
printf '.'
# the chrome extension
mkdir -p ./dist/chrome
cp -R ./src/extension/chrome ./dist/
cp ./src/extension/icon128.png ./dist/chrome/
rm ./dist/chrome/content.js
printf 'chrome bundle\n\n'
bundle ./src/extension/chrome/content.js ./dist/chrome/content.compiled.js
printf '.'
# the firefox extension
mkdir -p ./dist/firefox
cp -R ./src/extension/firefox ./dist/
cp ./src/extension/icon128.png ./dist/firefox/data
rm ./dist/firefox/data/content.js
printf 'ff bundle\n\n'
bundle ./src/extension/firefox/data/content.js ./dist/firefox/data/content.compiled.js
printf '.'
if [[ -z "$DEBUG" ]];
then
# no console.logs allowed in the release build
./node_modules/remove-console-logs/remove-console-logs `find ./dist/ -iname '*.js'`
gsed -i 's/ANX_MRAID_URL/http:\/\/cdn\.adnxs\.com\/js\/mraid\.js/' `find ./dist/ -iname '*.js'`
zip -r ./dist/chrome_release.zip ./dist/chrome
else
gsed -i 's/ANX_MRAID_URL/http:\/\/localhost:9000\/mraid\.js/' `find ./dist/ -iname '*.js'`
fi
printf 'done\n'
exit 0