#!/usr/bin/env node /** * generate-404.mjs * * Plain Node script (no runtime dependency) that writes the SPA fallback * `dist/404.html` from the built `dist/index.html`. * * The fallback must not be frozen at authoring time. A cold request to an * old URL is answered by the host with the `404.html` document, and that * document has to load the hashed assets of the build that is actually * published. A committed copy of a built index.html goes stale on the next * build, and the fallback then fetches an asset that no longer exists and * boots a blank app. So the fallback is derived from the build output on * every build, and this script runs last, after `vite build` has finished. * * The fallback carries the built index document verbatim, so it has the same * app entry script, stylesheet, favicon, meta tags, pre-paint theme script * and `