#!/usr/bin/env python3 """Rewrite HTML script tags to point at Vite's hashed production bundle. Usage: inject-hashed-filenames.py CONFIG_JSON [BUILD_DIR] CONFIG_JSON is a path to a JSON file listing the entries to rewrite. The schema mirrors the two hard-coded entries fewo-webapp had baked into an earlier version of this script: [ { "manifest": "static/dist/.vite/manifest.json", "html": "static/index.html", "old_src": "/static/dist/app.js" }, { "manifest": "static/guest/dist/.vite/manifest.json", "html": "static/guest/index.html", "old_src": "/guest/dist/guest-app.js" } ] All paths are resolved relative to BUILD_DIR (defaults to the repo root containing the config file's parent chain → `$PWD`). """ import json import os import re import sys def _build_pattern(old_src: str) -> "re.Pattern[str]": # Match `src` on