diff --git a/application/ui/rsbuild.config.ts b/application/ui/rsbuild.config.ts index 848c3ebf25..fc0e0f786e 100644 --- a/application/ui/rsbuild.config.ts +++ b/application/ui/rsbuild.config.ts @@ -128,6 +128,13 @@ export default defineConfig({ ...config, resolve: { ...config.resolve, extensions }, watchOptions: { ...config.watchOptions, ignored: ['**/src-tauri/**'] }, + // opencv.js (emscripten, under src/ so it's parsed) references + // `__dirname` for Node environment detection. Rspack's default + // `warn-mock` mocks it to '/' AND warns on every build. In the + // browser opencv takes the non-Node code path, so the mock value + // is never used — switch to 'mock' to keep the (identical) runtime + // behavior without the noisy build warning. + node: { ...config.node, __dirname: 'mock', __filename: 'mock' }, }; }, }, @@ -135,7 +142,10 @@ export default defineConfig({ headers: { 'Cross-Origin-Embedder-Policy': 'credentialless', 'Cross-Origin-Opener-Policy': 'same-origin', - 'Cache-Control': 'public, max-age=31536000, immutable', + // Must NOT be 'immutable': dev async chunks are not content-hashed, so an + // immutable cache causes the browser to keep serving stale chunk/HMR runtime + // URLs after a rebuild (stale worker imports, mismatched hmr.js client). + 'Cache-Control': 'no-cache', 'Content-Security-Policy': "default-src 'self'; " + "script-src 'self' 'unsafe-eval' blob:; " +