const { Webview } = require("webview-nodejs"); const { spawn } = require("child_process"); const PORT = 5173; const p = spawn("pnpm", ["vitepress", "dev", "--port", String(PORT), "docs"], { shell: true, stdio: "inherit", }); const w = new Webview(); w.title(require("./package.json").name); w.size(1920, 1280); w.init(/* js */ ` document.addEventListener('click', (ev) => { if (ev.target.matches('a')) { const href = ev.target.href || ''; if (href.startsWith('https://')) ev.preventDefault(); } }) `); w.navigate(`http://localhost:${PORT}`); w.show(); console.log(p.kill("SIGINT")); require("kill-port")(PORT);