Skip to content

Commit 3bffd14

Browse files
authored
fix: print error file path when using rollupOptions.output.dir (fix #9100) (#9111)
1 parent 15ff3a2 commit 3bffd14

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/vite/src/node/plugins/reporter.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
4747
content: string | Uint8Array,
4848
type: WriteType,
4949
maxLength: number,
50+
outDir = config.build.outDir,
5051
compressedSize = ''
5152
) {
52-
const outDir =
53+
outDir =
5354
normalizePath(
54-
path.relative(
55-
config.root,
56-
path.resolve(config.root, config.build.outDir)
57-
)
55+
path.relative(config.root, path.resolve(config.root, outDir))
5856
) + '/'
5957
const kibs = content.length / 1024
6058
const sizeColor = kibs > chunkLimit ? colors.yellow : colors.dim
@@ -137,7 +135,7 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
137135
}
138136
},
139137

140-
async writeBundle(_, output) {
138+
async writeBundle({ dir: outDir }, output) {
141139
let hasLargeChunks = false
142140

143141
if (shouldLogInfo) {
@@ -161,14 +159,16 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
161159
chunk.code,
162160
WriteType.JS,
163161
longest,
162+
outDir,
164163
await getCompressedSize(chunk.code)
165164
)
166165
if (chunk.map) {
167166
printFileInfo(
168167
chunk.fileName + '.map',
169168
chunk.map.toString(),
170169
WriteType.SOURCE_MAP,
171-
longest
170+
longest,
171+
outDir
172172
)
173173
}
174174
}
@@ -190,6 +190,7 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
190190
? WriteType.SOURCE_MAP
191191
: WriteType.ASSET,
192192
longest,
193+
outDir,
193194
isCSS ? await getCompressedSize(chunk.source) : undefined
194195
)
195196
}

0 commit comments

Comments
 (0)