Skip to content

Commit ce3fe23

Browse files
authored
fix: use loc.file from rollup errors if available (#19222)
1 parent ba03da2 commit ce3fe23

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/vite/src/node/build.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,12 @@ async function buildEnvironment(
635635
const stackOnly = extractStack(e)
636636

637637
let msg = colors.red((e.plugin ? `[${e.plugin}] ` : '') + e.message)
638-
if (e.id) {
638+
if (e.loc && e.loc.file && e.loc.file !== e.id) {
639+
msg += `\nfile: ${colors.cyan(
640+
`${e.loc.file}:${e.loc.line}:${e.loc.column}` +
641+
(e.id ? ` (${e.id})` : ''),
642+
)}`
643+
} else if (e.id) {
639644
msg += `\nfile: ${colors.cyan(
640645
e.id + (e.loc ? `:${e.loc.line}:${e.loc.column}` : ''),
641646
)}`

0 commit comments

Comments
 (0)