diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index ecf57cb07a3be5..fdf13ded820b28 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -308,7 +308,11 @@ const hasDocument = 'document' in globalThis function createErrorOverlay(err: ErrorPayload['err']) { clearErrorOverlay() - document.body.appendChild(new ErrorOverlay(err)) + const { customElements } = globalThis + if (customElements) { + const ErrorOverlayConstructor = customElements.get(overlayId)! + document.body.appendChild(new ErrorOverlayConstructor(err)) + } } function clearErrorOverlay() {