wilddragon-site/build.sh
Zac Gaetano d4d46b085e fix(deploy): content-hash cache-busting + block source/config leaks + real 404s
- build.sh stamps ?v=<md5> on JS/CSS refs; Cloudflare was serving 4h-stale bundles
- nginx: 404 for .mjs/.md/.yml/.sh/.conf/Dockerfile/dotfiles (build-pages.mjs, README, compose were public)
- nginx: unknown paths 404 instead of soft-404 SPA fallback (Search Console soft-404s)
- track live nginx.conf in repo
2026-10-01 20:43:16 -04:00

13 lines
618 B
Bash
Executable file

#!/bin/sh
# Build minified bundles from the JSX sources (matches what's deployed).
set -e
cd "$(dirname "$0")"
for f in components tweaks-panel app; do
npx -y esbuild@0.24 "$f.jsx" --loader:.jsx=jsx --jsx=transform --minify --target=es2020 --outfile="$f.min.js" --log-level=warning
done
node build-pages.mjs
# Cache-bust: Cloudflare caches assets 4h; stamp content hashes into HTML refs.
for a in components.min.js tweaks-panel.min.js app.min.js styles.css; do
h=$(md5sum "$a" | cut -c1-8)
find . -name index.html -not -path './node_modules/*' -exec sed -i -E "s#(\"/$a)(\?v=[0-9a-f]+)?\"#\1?v=$h\"#g" {} +
done