From 4b632aeca0408354077bfc24ad5cf82153b9ce48 Mon Sep 17 00:00:00 2001 From: Giancarlo Tutini Amaral <39142169+gTutini@users.noreply.github.com> Date: Thu, 27 Jun 2024 06:57:22 -0300 Subject: [PATCH] fix: add the delay to the server restart function (#24) Co-authored-by: Giancarlo Tutini --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 0ca855e..0dde89d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -88,7 +88,9 @@ function VitePluginRestart(options: VitePluginRestartOptions = {}): Plugin { function handleFileChange(file: string) { if (micromatch.isMatch(file, restartGlobs)) { timerState = 'restart' - server.restart() + schedule(() => { + server.restart() + }) } else if (micromatch.isMatch(file, reloadGlobs) && timerState !== 'restart') { timerState = 'reload'