From ea77b74312c8df65c180addf6c2acf76342e00e8 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Fri, 13 Mar 2026 11:09:24 -0700 Subject: [PATCH] fix(plugin-vite): improve child logging --- packages/plugin/vite/src/VitePlugin.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/plugin/vite/src/VitePlugin.ts b/packages/plugin/vite/src/VitePlugin.ts index 3fab2d905d..bf9f5152c1 100644 --- a/packages/plugin/vite/src/VitePlugin.ts +++ b/packages/plugin/vite/src/VitePlugin.ts @@ -42,7 +42,13 @@ function spawnViteBuild( FORGE_VITE_INDEX: String(index), FORGE_VITE_CONFIG: JSON.stringify(pluginConfig), }, - stdio: ['ignore', 'ignore', 'pipe'], + stdio: ['ignore', 'pipe', 'pipe'], + }); + + let stdout = ''; + child.stdout.setEncoding('utf8'); + child.stdout.on('data', (chunk) => { + stdout += chunk; }); let stderr = ''; @@ -52,15 +58,17 @@ function spawnViteBuild( }); child.on('error', reject); - child.on('close', (code) => { + child.on('close', (code, signal) => { if (code === 0) { resolve(); } else { + const output = [stdout, stderr].filter(Boolean).join('\n'); + const reason = signal + ? `killed by signal ${signal}` + : `exited with code ${code}`; reject( new Error( - `Vite build subprocess exited with code ${code}${ - stderr ? `:\n${stderr}` : '' - }`, + `Vite build subprocess ${reason}${output ? `:\n${output}` : ''}`, ), ); }