refactor(electron): server side plugin (#3360)

This commit is contained in:
Alex Yang
2023-07-25 14:32:34 -07:00
committed by GitHub
parent 521e505a01
commit 10f879f29a
28 changed files with 79 additions and 840 deletions
-29
View File
@@ -96,37 +96,8 @@ async function watchLayers() {
});
}
async function watchWorkers() {
return new Promise(async resolve => {
let initialBuild = false;
const buildContext = await esbuild.context({
...common.workers,
plugins: [
...(common.workers.plugins ?? []),
{
name: 'electron-dev:reload-app-on-workers-change',
setup(build) {
build.onEnd(() => {
if (initialBuild) {
console.log(`[workers] has changed, [re]launching electron...`);
spawnOrReloadElectron();
} else {
resolve();
initialBuild = true;
}
});
},
},
],
});
await buildContext.watch();
});
}
async function main() {
await watchLayers();
await watchWorkers();
if (watchMode) {
console.log(`Watching for changes...`);