diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index dbfc8b9347b1d2..87b5d1e33cf01c 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -632,7 +632,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { return } // Unexpected error, log the issue but avoid an unhandled exception - config.logger.error(e.message, { error: e }) + config.logger.error(`Pre-transform error: ${e.message}`, { + error: e, + timestamp: true, + }) }) } } else if (!importer.startsWith(withTrailingSlash(clientDir))) { diff --git a/packages/vite/src/node/server/middlewares/indexHtml.ts b/packages/vite/src/node/server/middlewares/indexHtml.ts index 678c09fc7c029c..c9d9228a0d79ef 100644 --- a/packages/vite/src/node/server/middlewares/indexHtml.ts +++ b/packages/vite/src/node/server/middlewares/indexHtml.ts @@ -360,6 +360,9 @@ function preTransformRequest(server: ViteDevServer, url: string, base: string) { return } // Unexpected error, log the issue but avoid an unhandled exception - server.config.logger.error(e.message) + server.config.logger.error(`Pre-transform error: ${e.message}`, { + error: e, + timestamp: true, + }) }) }