diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts index 42e5bbac76316a..16edee000fbb82 100644 --- a/packages/vite/src/node/plugins/esbuild.ts +++ b/packages/vite/src/node/plugins/esbuild.ts @@ -437,11 +437,14 @@ function reloadOnTsconfigChange(changedFile: string) { // reset tsconfck so that recompile works with up2date configs initTSConfck(server.config).finally(() => { - // force full reload - server.ws.send({ - type: 'full-reload', - path: '*' - }) + // server may not be available if vite config is updated at the same time + if (server) { + // force full reload + server.ws.send({ + type: 'full-reload', + path: '*' + }) + } }) } }