fix(vite): add back support for Preact DevTools (#3266)
This commit is contained in:
@@ -6,9 +6,13 @@ export function clientEntryPlugin(options: ResolvedFreshViteConfig): Plugin {
|
|||||||
const modNameUser = "fresh:client-entry-user";
|
const modNameUser = "fresh:client-entry-user";
|
||||||
|
|
||||||
let clientEntry = "";
|
let clientEntry = "";
|
||||||
|
let isDev = false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: "fresh:client-entry",
|
name: "fresh:client-entry",
|
||||||
|
config(_, env) {
|
||||||
|
isDev = env.command === "serve";
|
||||||
|
},
|
||||||
applyToEnvironment(env) {
|
applyToEnvironment(env) {
|
||||||
return env.name === "client";
|
return env.name === "client";
|
||||||
},
|
},
|
||||||
@@ -33,7 +37,9 @@ export function clientEntryPlugin(options: ResolvedFreshViteConfig): Plugin {
|
|||||||
exists = false;
|
exists = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `export * from "fresh/runtime-client";
|
return `
|
||||||
|
${isDev ? 'import "preact/debug"' : ""}
|
||||||
|
export * from "fresh/runtime-client";
|
||||||
${exists ? `import "fresh:client-entry-user";` : ""}
|
${exists ? `import "fresh:client-entry-user";` : ""}
|
||||||
|
|
||||||
if (import.meta.hot) {
|
if (import.meta.hot) {
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ export function registerStaticFile(prepared) {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
code += `if (import.meta.hot) import.meta.hot.accept();\n`;
|
code = `import "preact/debug";
|
||||||
|
${code}
|
||||||
|
if (import.meta.hot) import.meta.hot.accept();`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|||||||
Reference in New Issue
Block a user