Skip to content

Commit

Permalink
fix: simplify prettyUrl (#12488)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Mar 20, 2023
1 parent a53feb5 commit ebe5aa5
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,7 @@ export function prettifyUrl(url: string, root: string): string {
url = removeTimestampQuery(url)
const isAbsoluteFile = url.startsWith(root)
if (isAbsoluteFile || url.startsWith(FS_PREFIX)) {
let file = path.relative(root, isAbsoluteFile ? url : fsPathFromId(url))
const seg = file.split('/')
const npmIndex = seg.indexOf(`node_modules`)
const isSourceMap = file.endsWith('.map')
if (npmIndex > 0) {
file = seg[npmIndex + 1]
if (file.startsWith('@')) {
file = `${file}/${seg[npmIndex + 2]}`
}
file = `npm: ${colors.dim(file)}${isSourceMap ? ` (source map)` : ``}`
}
const file = path.relative(root, isAbsoluteFile ? url : fsPathFromId(url))
return colors.dim(file)
} else {
return colors.dim(url)
Expand Down

0 comments on commit ebe5aa5

Please sign in to comment.