-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathbuild-site.sh
More file actions
executable file
·64 lines (52 loc) · 2.1 KB
/
Copy pathbuild-site.sh
File metadata and controls
executable file
·64 lines (52 loc) · 2.1 KB
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
#!/usr/bin/env bash
#
# Builds the deployable site: the website at the root, the documentation
# under /docs, assembled into _site/.
#
# ./scripts/build-site.sh build everything and assemble
# ./scripts/build-site.sh docs just the documentation
# ./scripts/build-site.sh website just the website
# ./scripts/build-site.sh assemble just combine what is already built
#
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OUT="$ROOT/_site"
DOMAIN="www.dropzone.dev"
say() { printf '\033[1m==>\033[0m %s\n' "$1"; }
die() { printf '\033[31merror:\033[0m %s\n' "$1" >&2; exit 1; }
build_docs() {
say "Building the documentation"
pnpm --filter @dropzone/docs run build
}
build_website() {
# The website demos the library from this workspace rather than npm, and
# resolves it through dist/, so it has to exist first.
say "Building the library"
pnpm --filter dropzone run build
say "Building the website"
pnpm --filter @dropzone/website run build
}
assemble() {
say "Assembling $OUT"
[ -d "$ROOT/apps/website/build" ] || die "apps/website/build is missing -- build the website first"
[ -d "$ROOT/apps/docs/build" ] || die "apps/docs/build is missing -- build the docs first"
rm -rf "$OUT"
mkdir -p "$OUT"
cp -R "$ROOT/apps/website/build/." "$OUT/"
cp -R "$ROOT/apps/docs/build" "$OUT/docs"
# Kept alongside the repository setting so the domain survives a deployment
# made before that setting is applied.
echo "$DOMAIN" > "$OUT/CNAME"
# A build that quietly produced nothing should fail here rather than deploy
# an empty site over a working one.
[ -f "$OUT/index.html" ] || die "the website produced no index.html"
[ -f "$OUT/docs/index.html" ] || die "the documentation produced no index.html"
say "Done: $(du -sh "$OUT" | cut -f1) in _site ($(find "$OUT" -name '*.html' | wc -l | tr -d ' ') pages)"
}
case "${1:-all}" in
docs) build_docs ;;
website) build_website ;;
assemble) assemble ;;
all) build_docs; build_website; assemble ;;
*) die "unknown step '$1' (expected: docs, website, assemble, all)" ;;
esac