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:
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user