Skip to content

Commit 3c1bde3

Browse files
authored
fix(client): fix vite error path (#17744)
1 parent a7f9827 commit 3c1bde3

File tree

1 file changed

+3
-1
lines changed
  • packages/vite/src/node/server/middlewares

1 file changed

+3
-1
lines changed

packages/vite/src/node/server/middlewares/error.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import path from 'node:path'
12
import colors from 'picocolors'
23
import type { RollupError } from 'rollup'
34
import type { Connect } from 'dep-types/connect'
45
import strip from 'strip-ansi'
56
import type { ErrorPayload } from 'types/hmrPayload'
67
import { pad } from '../../utils'
78
import type { ViteDevServer } from '../..'
9+
import { CLIENT_PUBLIC_PATH } from '../../constants'
810

911
export function prepareError(err: Error | RollupError): ErrorPayload['err'] {
1012
// only copy the information we need and avoid serializing unnecessary
@@ -82,7 +84,7 @@ export function errorMiddleware(
8284
'\\u003c',
8385
)}
8486
try {
85-
const { ErrorOverlay } = await import('/@vite/client')
87+
const { ErrorOverlay } = await import(${JSON.stringify(path.posix.join(server.config.base, CLIENT_PUBLIC_PATH))})
8688
document.body.appendChild(new ErrorOverlay(error))
8789
} catch {
8890
const h = (tag, text) => {

0 commit comments

Comments
 (0)