Skip to content

Commit

Permalink
fix(reporter): build.assetsDir should not impact output when in lib m…
Browse files Browse the repository at this point in the history
…ode (#12108)
  • Loading branch information
sun0day committed Mar 12, 2023
1 parent 46c5f46 commit b12f457
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/vite/src/node/plugins/reporter.ts
Expand Up @@ -188,7 +188,7 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
path.resolve(config.root, outDir ?? config.build.outDir),
),
)
const assetsDir = `${config.build.assetsDir}/`
const assetsDir = path.join(config.build.assetsDir, '/')

for (const group of groups) {
const filtered = entries.filter((e) => e.group === group.name)
Expand All @@ -199,14 +199,15 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
if (isLarge) hasLargeChunks = true
const sizeColor = isLarge ? colors.yellow : colors.dim
let log = colors.dim(relativeOutDir + '/')
log += entry.name.startsWith(assetsDir)
? colors.dim(assetsDir) +
group.color(
entry.name
.slice(assetsDir.length)
.padEnd(longest + 2 - assetsDir.length),
)
: group.color(entry.name.padEnd(longest + 2))
log +=
!config.build.lib && entry.name.startsWith(assetsDir)
? colors.dim(assetsDir) +
group.color(
entry.name
.slice(assetsDir.length)
.padEnd(longest + 2 - assetsDir.length),
)
: group.color(entry.name.padEnd(longest + 2))
log += colors.bold(
sizeColor(displaySize(entry.size).padStart(sizePad)),
)
Expand Down

0 comments on commit b12f457

Please sign in to comment.