1
0
forked from baron/baron-sso

perf(userfront): optimize login web loading

This commit is contained in:
2026-05-15 14:16:34 +09:00
parent 57456bd4cd
commit 4346f48bbe
12 changed files with 383 additions and 62 deletions

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
fail() {
echo "[userfront-loading-policy] $*" >&2
exit 1
}
if rg -n "FontLoader|assets/fonts/NotoSansKR|_loadBundledFonts" userfront/lib userfront/pubspec.yaml; then
fail "userfront must not block first render on bundled NotoSansKR font loading"
fi
if rg -n "fontFamily:\s*['\"]NotoSansKR['\"]" userfront/lib; then
fail "userfront theme must use the platform default font"
fi
if rg -n "await ThemeController\.(app|auth)\.restore" userfront/lib/main.dart; then
fail "theme restore must not block the first render"
fi
if rg -n "fonts\.googleapis\.com/icon\?family=Material\+Icons" userfront/web/index.html; then
fail "userfront must not load Google Material Icons stylesheet on the login critical path"
fi
if rg -n -- "--no-tree-shake-icons" userfront/Dockerfile userfront-e2e/package.json; then
fail "userfront web release build must allow icon tree shaking"
fi
rg -q "optimize-web-build\.mjs" userfront/Dockerfile || fail "Docker build must hash and pre-compress Flutter web entrypoints"
rg -q "nginx-mod-http-brotli" userfront/Dockerfile || fail "runtime image must install the nginx Brotli module"
rg -Fq "main\\.dart\\.[0-9a-f]{12}" userfront/nginx.conf || fail "hashed app entrypoints must use immutable cache"
rg -q "brotli_static\s+on;" userfront/nginx.conf || fail "nginx must serve pre-compressed brotli assets"
rg -q "brotliCompressSync" userfront/scripts/optimize-web-build.mjs || fail "Docker build optimization must generate brotli assets"
if rg -n "gzip|gzipSync|\\.gz" userfront/nginx.conf userfront/scripts/optimize-web-build.mjs; then
fail "userfront web compression must be managed as brotli-only"
fi
rg -q "Cache-Control.*no-cache" userfront/nginx.conf || fail "HTML/app shell must use no-cache revalidation"
rg -q "Cache-Control.*immutable" userfront/nginx.conf || fail "versioned static assets must use immutable cache"