Vite plugin that captures console logs and HMR errors during development, allowing inspection and assertion of log output. Current stable version is 0.1.4 (released July 2024). Active development. Differentiators: integrates directly with Vite's HMR pipeline, captures both standard console logs and HMR-specific errors, and provides a simple API to retrieve captured logs for testing or debugging. Unlike generic log interceptors, it works seamlessly with Vite's dev server.
npm install vite-log-captureVerified import paths — ran on the pinned version, not inferred.
Shows basic plugin setup in vite.config.ts, capturing console logs in application code, and retrieving captured logs.
Upgrade Vite to version 7.0.0 or later.
Call captureLogs() at the earliest point in your application, typically before any imports or module evaluation.
After retrieving logs, call clearCapturedLogs() to avoid accumulating duplicate entries.
Run 'npm install vite@latest' to upgrade to Vite 7.0.0+.
Use import statement instead: 'import { captureLogs } from "vite-log-capture"'Ensure import { captureLogs } from 'vite-log-capture' is at the top of the file and that the plugin is applied before using captureLogs.