-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bakefile
54 lines (42 loc) · 840 Bytes
/
Bakefile
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
#!/usr/bin/env bash
trap clean 1 2 3 6 9
SRC="src/client/main.ts"
PUBLIC="public"
DIST="dist"
BUILD="bun build --target=browser --format=esm --sourcemap=inline --minify"
setup() {
bun install
}
format() {
prettier --write .
}
build() {
if [ -e $DIST ]; then
echo >&2 "Error: Already built. Run \`clean\` first"
echo >&2
exit 1
fi
mkdir $DIST
cp $PUBLIC/* $DIST/
$BUILD $SRC --outdir=$DIST
}
serve() {
export DIST
bun --hot src/server/main.ts
}
dev() {
# We serve from `public` in dev mode, because
# because otherwise the server has to be restarted
# for static assets to be rebuilt.
DIST=$PUBLIC serve &
$BUILD $SRC --watch --outdir=$PUBLIC
}
clean() {
p:clean_if_exists $DIST
p:clean_if_exists $PUBLIC/main.js
}
p:clean_if_exists() {
if [ -e "$1" ]; then
rm -rf "$1"
fi
}