fix(dashboard): reload on stale chunk after redeploy

Builds now emit version.json + a __BUILD_VERSION__ define. The client
re-checks the remote version on visibilitychange/focus and reloads on
mismatch, so a backgrounded tab doesn't hit a 404'd hashed chunk and
surface "'text/html' is not a valid JavaScript MIME type" when opening
Settings. ErrorBoundary catches stale-chunk errors as a safety net.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Fusion
2026-04-26 09:48:04 -07:00
committed by gsxdsm
parent a692edf079
commit ca26ae0781
6 changed files with 111 additions and 4 deletions

View File

@@ -1,10 +1,28 @@
import { defineConfig } from "vite";
import { defineConfig, type Plugin } from "vite";
import react from "@vitejs/plugin-react";
import { resolve } from "node:path";
import { writeFileSync } from "node:fs";
import { randomBytes } from "node:crypto";
const buildVersion = `${Date.now().toString(36)}-${randomBytes(4).toString("hex")}`;
function emitVersionJson(): Plugin {
return {
name: "fusion-emit-version-json",
apply: "build",
closeBundle() {
const outFile = resolve(__dirname, "dist/client/version.json");
writeFileSync(outFile, `${JSON.stringify({ version: buildVersion })}\n`);
},
};
}
export default defineConfig({
root: "app",
plugins: [react()],
plugins: [react(), emitVersionJson()],
define: {
__BUILD_VERSION__: JSON.stringify(buildVersion),
},
resolve: {
alias: {
"@fusion/core": resolve(__dirname, "../core/src/types.ts"),