-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaudit-bundle.sh
More file actions
executable file
·29 lines (24 loc) · 1.02 KB
/
Copy pathaudit-bundle.sh
File metadata and controls
executable file
·29 lines (24 loc) · 1.02 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
#!/usr/bin/env bash
# Run the bundle-size audit safely. Vite (with emptyOutDir default=true) wipes
# dist/ before building → `dist/fast-search-card.js` gets deleted locally
# without `build.sh`'s wrapper-injection step. This script runs the audit and
# then restores the committed wrapper file so the working tree stays sane.
#
# Output: aggregated leaderboard on stdout + dist/bundle-stats.html opens.
#
# To regenerate just the production bundle, use `./build.sh` instead.
set -e
ROOT="$(git rev-parse --show-toplevel)"
cd "$ROOT"
echo "== Running vite with ANALYZE=1 (this empties dist/) =="
ANALYZE=1 npm run build
echo ""
echo "== Parsing bundle-stats.html =="
node analyze-bundle.js
echo ""
echo "== Restoring dist/fast-search-card.js from git =="
# vite wiped it; the committed copy is the last production-built wrapper.
git restore dist/fast-search-card.js
echo ""
echo "✓ Audit complete. bundle-stats.html generated. dist/fast-search-card.js"
echo " restored from HEAD (run ./build.sh to actually re-produce a fresh one)."