-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
43 lines (37 loc) · 1.08 KB
/
build.sh
File metadata and controls
43 lines (37 loc) · 1.08 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
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
mkdir -p dist .build
# Bundle local app ES modules
./bin/esbuild viewer/src/main.js --bundle --format=iife --outfile=.build/bundle.js
# Inline rule: replaces any tag with data-local="path" with its file contents.
INLINE_RULE='
match($0, /data-local="([^"]+)"/, m) {
file = "viewer/" m[1]
if (mode == "lite" && m[1] ~ /^vendor\//) {
gsub(/ *data-local="[^"]*"/, "")
print
next
}
if ($0 ~ /<script/) {
print "<script type=\"text/javascript\">"
while ((getline line < file) > 0) print line
close(file)
print "</script>"
} else if ($0 ~ /<link/) {
print "<style type=\"text/css\">"
while ((getline line < file) > 0) print line
close(file)
print "</style>"
}
next
}
{ print }
'
# Full build: monolithic offline build
awk -v mode=full "$INLINE_RULE" viewer/index.html > dist/claude-keeper.html
echo "Built: dist/claude-keeper.html"
# Lite build: vendor libraries load from CDN
awk -v mode=lite "$INLINE_RULE" viewer/index.html > dist/claude-keeper-lite.html
echo "Built: dist/claude-keeper-lite.html"