Skip to content

Commit

Permalink
try to fix vite preload error with chunks and reloading (#741)
Browse files Browse the repository at this point in the history
  • Loading branch information
cstenglein committed Jul 9, 2024
1 parent 74956fc commit 96dd01f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ declare module "i18next" {
}
}

// see https://vitejs.dev/guide/build#load-error-handling
window.addEventListener("vite:preloadError", (event) => {
window.location.reload();
});

const container = document.getElementById("root") as HTMLElement;
const root = createRoot(container);
root.render(
Expand Down
6 changes: 6 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export default defineConfig({
plugins: [react(), viteTsconfigPaths(), svgr(), eslint()],
build: {
outDir: "build",
rollupOptions: {
output: {
// see https://github.com/vitejs/vite/issues/11804#issuecomment-2009619365
chunkFileNames: 'chunk-[hash].js'
}
}
},
resolve: {
alias: {
Expand Down

0 comments on commit 96dd01f

Please sign in to comment.