This commit is contained in:
Rizky 2024-08-14 19:08:16 +07:00
parent 89cf81b657
commit 788c4d0070
2 changed files with 14 additions and 27 deletions

View File

@ -85,18 +85,16 @@ export const initFrontEnd = async (
const srv = code.internal.server[id_site];
if (
filename?.startsWith("node_modules") ||
filename?.startsWith("server.ts") ||
filename?.startsWith("typings")
)
return;
if (
filename?.endsWith(".tsx") ||
filename?.endsWith(".ts") ||
filename?.endsWith(".css") ||
filename?.endsWith(".html")
) {
console.log(filename);
if (typeof fe !== "undefined" && !fe.rebuilding) {
fe.rebuilding = true;
clearTimeout(fe.timeout);
@ -112,15 +110,6 @@ export const initFrontEnd = async (
}
}, 500);
}
if (typeof srv !== "undefined" && !srv.rebuilding && srv.ctx) {
srv.rebuilding = true;
try {
await srv.ctx.rebuild();
await server.init(id_site);
} catch (e) {}
srv.rebuilding = false;
}
}
}
),

View File

@ -40,15 +40,18 @@ export const initServer = async (
treeShaking: true,
format: "cjs",
logLevel: "silent",
// plugins: [
// {
// name: "prasi",
// setup(build) {
// build.onEnd(() => {
// });
// },
// },
// ],
plugins: [
{
name: "prasi",
setup(build) {
build.onEnd((e) => {
if (e.errors.length === 0) {
server.init(id_site);
}
});
},
},
],
banner: {
js: `\
const _fs = require('node:fs/promises');
@ -109,10 +112,5 @@ if (typeof global.server_hook === "function") {
}),
};
code.internal.server[id_site].rebuilding = true;
try {
await code.internal.server[id_site].ctx.rebuild();
await server.init(id_site);
} catch (e) {}
code.internal.server[id_site].rebuilding = false;
code.internal.server[id_site].ctx.watch();
};