Vite plugin for automatically injecting vConsole (a lightweight, extendable front-end developer tool for mobile web pages) into your application during development or specific build modes. Current stable version is 2.1.1, released in 2023. It supports Vite v2+, Node.js >=12, and works with both Vue and React. Key differentiators: dynamic configuration, custom vConsole plugins, multi-page support, and environment-aware enabling/disabling. Compared to alternatives like manually adding vConsole, this plugin automates the setup and teardown process, ensuring vConsole is only loaded when needed (e.g., development or test builds).
npm install vite-plugin-vconsoleVerified import paths — ran on the pinned version, not inferred.
Shows basic Vite config with vite-plugin-vconsole for Vue, enabling vConsole in non-production environments.
Replace localEnable with enabled. The enabled option now supports boolean or function returning boolean.
Follow new plugin structure: plugin: [{ id: 'myPlugin', name: 'My Plugin', event: [ { eventName: 'init', callback() {} } ] }]Import { viteVConsole } instead of { vconsole }.Run 'npm install vconsole' without --save-dev (or -S).
Use path.resolve('src/main.ts') or __dirname + '/src/main.ts'.Use 'import type { ViteVConsoleOptions } from 'vite-plugin-vconsole'.npm install vconsole --save
Change to `import { viteVConsole } from 'vite-plugin-vconsole'`Use path.resolve() to get absolute path: `entry: path.resolve('src/main.ts')`Ensure vconsole is in dependencies, not devDependencies.