-
Notifications
You must be signed in to change notification settings - Fork 0
/
prod.sh
67 lines (50 loc) · 992 Bytes
/
prod.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
#!/bin/env sh
# clean
rm -r prod
# output dir
mkdir prod
mkdir prod/web
mkdir prod/pkg
# build
sh build_wasm.sh 3 &
tsc -p . &
sass ./web/index.scss ./web/index.css
pstree $$
wait
# minify
FILES="web/index.js
web/worker.js
web/index.html
web/index.css
pkg/cambridge_asm_web.js"
for f in ${FILES}; do
minify "${f}" >"prod/${f}" &
done
pstree $$
wait
mv prod/web/* prod/ &
mv prod/pkg/* prod/
rm -r prod/web prod/pkg
# copy WASM
cp "pkg/cambridge_asm_web_bg.wasm" "prod/cambridge_asm_web_bg.wasm"
# get polyfill
curl -L "https://unpkg.com/module-workers-polyfill@0.3.2/module-workers-polyfill.min.js" --output "prod/module-workers-polyfill.min.js"
# copy fonts
cp -r web/fonts prod/fonts
# check if everything exists in prod
CHECK="index.js
worker.js
index.html
index.css
cambridge_asm_web.js
module-workers-polyfill.min.js
cambridge_asm_web_bg.wasm
fonts"
cd prod || exit 1
for f in ${CHECK}; do
if stat "${f}" >/dev/null; then
echo "${f} exists."
else
exit 1
fi
done