fix(vite): workaround for FOUC with tailwind (#3407)

Fixes https://github.com/denoland/fresh/issues/3379
This commit is contained in:
Marvin Hagemeister
2025-09-12 12:34:23 +02:00
committed by GitHub
parent e5bc9194e9
commit 7ce6aeff8b
5 changed files with 119 additions and 15 deletions
+19
View File
@@ -0,0 +1,19 @@
import type { UpdatePayload } from "vite";
import { hashCode } from "./shared.ts";
if (import.meta.hot) {
import.meta.hot.on("fresh:reload", () => {
window.location.reload();
});
import.meta.hot.on("vite:beforeUpdate", (module: UpdatePayload) => {
module.updates.forEach((update) => {
const moduleStyle = document.querySelector(
`[vite-module-id="${hashCode(update.acceptedPath)}"]`,
);
if (moduleStyle) {
moduleStyle.remove();
}
});
});
}