mirror of
https://github.com/alrayyes/wiki.git
synced 2025-05-01 14:38:14 +00:00
fix rebuild debouncing
This commit is contained in:
parent
07a327e05a
commit
0998bc355e
3 changed files with 42 additions and 37 deletions
quartz
|
@ -355,6 +355,7 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
|
|||
],
|
||||
})
|
||||
|
||||
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}`)
|
||||
|
@ -380,6 +381,11 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
|
|||
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 = []
|
||||
|
@ -457,7 +463,7 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
|
|||
})
|
||||
.on("all", async () => {
|
||||
console.log(chalk.yellow("Detected a source code change, doing a hard rebuild..."))
|
||||
await build(clientRefresh)
|
||||
rebuild(clientRefresh)
|
||||
})
|
||||
} else {
|
||||
await build(() => {})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue