fix(vite): workaround for FOUC with tailwind (#3407)
Fixes https://github.com/denoland/fresh/issues/3379
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user