| | |
| | | ], |
| | | }) |
| | | |
| | | const timeoutIds = new Set() |
| | | const build = async (clientRefresh) => { |
| | | const result = await ctx.rebuild().catch((err) => { |
| | | console.error(`${chalk.red("Couldn't parse Quartz configuration:")} ${fp}`) |
| | |
| | | clientRefresh() |
| | | } |
| | | |
| | | const rebuild = (clientRefresh) => { |
| | | timeoutIds.forEach((id) => clearTimeout(id)) |
| | | timeoutIds.add(setTimeout(() => build(clientRefresh), 250)) |
| | | } |
| | | |
| | | if (argv.serve) { |
| | | const wss = new WebSocketServer({ port: 3001 }) |
| | | const connections = [] |
| | |
| | | }) |
| | | .on("all", async () => { |
| | | console.log(chalk.yellow("Detected a source code change, doing a hard rebuild...")) |
| | | await build(clientRefresh) |
| | | rebuild(clientRefresh) |
| | | }) |
| | | } else { |
| | | await build(() => {}) |