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]; const srv = code.internal.server[id_site];
if ( if (
filename?.startsWith("node_modules") || filename?.startsWith("node_modules") ||
filename?.startsWith("server.ts") ||
filename?.startsWith("typings") filename?.startsWith("typings")
) )
return; return;
if ( if (
filename?.endsWith(".tsx") || filename?.endsWith(".tsx") ||
filename?.endsWith(".ts") || filename?.endsWith(".ts") ||
filename?.endsWith(".css") || filename?.endsWith(".css") ||
filename?.endsWith(".html") filename?.endsWith(".html")
) { ) {
console.log(filename);
if (typeof fe !== "undefined" && !fe.rebuilding) { if (typeof fe !== "undefined" && !fe.rebuilding) {
fe.rebuilding = true; fe.rebuilding = true;
clearTimeout(fe.timeout); clearTimeout(fe.timeout);
@ -112,15 +110,6 @@ export const initFrontEnd = async (
} }
}, 500); }, 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, treeShaking: true,
format: "cjs", format: "cjs",
logLevel: "silent", logLevel: "silent",
// plugins: [ plugins: [
// { {
// name: "prasi", name: "prasi",
// setup(build) { setup(build) {
// build.onEnd(() => { build.onEnd((e) => {
// }); if (e.errors.length === 0) {
// }, server.init(id_site);
// }, }
// ], });
},
},
],
banner: { banner: {
js: `\ js: `\
const _fs = require('node:fs/promises'); const _fs = require('node:fs/promises');
@ -109,10 +112,5 @@ if (typeof global.server_hook === "function") {
}), }),
}; };
code.internal.server[id_site].rebuilding = true; code.internal.server[id_site].ctx.watch();
try {
await code.internal.server[id_site].ctx.rebuild();
await server.init(id_site);
} catch (e) {}
code.internal.server[id_site].rebuilding = false;
}; };