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
@@ -21,11 +21,13 @@ export function clientEntryPlugin(options: ResolvedFreshViteConfig): Plugin {
},
resolveId: {
filter: {
id: /(fresh:client-entry|fresh:client-entry-user)/,
id: /(fresh:client-entry|fresh:client-entry-user|fresh:client-quirks)/,
},
handler(id) {
if (id === modName) {
return `\0${modName}`;
} else if (id === "fresh:client-quirks") {
return "@fresh/plugin-vite/client";
} else if (id === modNameUser) {
return clientEntry;
}
@@ -48,17 +50,7 @@ export function clientEntryPlugin(options: ResolvedFreshViteConfig): Plugin {
${isDev ? 'import "preact/debug"' : ""}
export * from "fresh/runtime-client";
${exists ? `import "fresh:client-entry-user";` : ""}
if (import.meta.hot) {
import.meta.hot.accept(() => {
console.log("accepting")
});
import.meta.hot.on("fresh:reload", ev => {
console.log(ev)
window.location.reload();
});
}
`;
import "@fresh/plugin-vite/client";`;
},
},
};