Skip to content

Commit

Permalink
fix(client): fix vite error path (#17744)
Browse files Browse the repository at this point in the history
  • Loading branch information
coderwei99 authored Jul 23, 2024
1 parent a7f9827 commit 3c1bde3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vite/src/node/server/middlewares/error.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import path from 'node:path'
import colors from 'picocolors'
import type { RollupError } from 'rollup'
import type { Connect } from 'dep-types/connect'
import strip from 'strip-ansi'
import type { ErrorPayload } from 'types/hmrPayload'
import { pad } from '../../utils'
import type { ViteDevServer } from '../..'
import { CLIENT_PUBLIC_PATH } from '../../constants'

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

0 comments on commit 3c1bde3

Please sign in to comment.