-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-wasm.sh
executable file
·52 lines (45 loc) · 1014 Bytes
/
build-wasm.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
#! /bin/bash
# build-wasm.sh: Builds and launches the WebAssembly project
# You could probably use like turborepo or something to do this,
# but our example is pretty small
function build-wasm-module {
echo "🕸️🦀 Building wasm + bindings"
pushd "./packages/web/rustlib-webpack-ts"
wasm-pack build && popd || popd
}
function build-app {
echo "🕸️📦🦀 Building wasm + bindings"
npm run build --workspace="ts-primes"
}
function start-app {
echo "🕸️🦀🖥️ Starting dev server"
npm run start --workspace="ts-primes"
}
function install {
rm -rf ./node_modules
rm package-lock.json
build-wasm-module
npm install
}
readonly SCRIPT=$1
if [ -z $SCRIPT ]; then
echo "no argument specified. building wasm & app"
build-wasm-module
build-app
else
case $SCRIPT in
install)
install
;;
build-wasm)
build-wasm-module
;;
build-app)
build-app
;;
start-app)
build-wasm-module
start-app
;;
esac
fi