
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
vite-plugin-ssr-vconsole
Advanced tools
vite ssr plugin for vconsole
A plugin for Vite v2+ in ssr that helps developers easily use the functions of VConsole in various environments.
English | ä¸ć–‡
node version: >=12.0.0
vite version: >=2.0.0
# npm
npm i vite-plugin-vconsole -D
npm i vconsole -S
# yarn
yarn add vconsole
yarn add vite-plugin-vconsole -D
# pnpm
pnpm add vconsole
pnpm add -D vite-plugin-vconsole
# vue
cd ./example/vue-demo
yarn install
yarn dev
# react
cd ./example/react-demo
yarn install
yarn dev
// tips: If the reference path hint does not exist, you can import the @types/node package
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { viteVConsole } from 'vite-plugin-vconsole';
import * as path from 'path'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
viteVConsole({
entry: path.resolve('src/main.ts'), // or you can use entry: [path.resolve('src/main.ts')]
enabled: true,
config: {
maxLogNumber: 1000,
theme: 'dark'
}
})
]
});
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { viteVConsole } from 'vite-plugin-vconsole';
import * as path from 'path'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
viteVConsole({
entry: [path.resolve('src/main.ts')], // entry for each page, different from the above
enabled: true,
config: {
maxLogNumber: 1000,
theme: 'dark'
}
})
]
});
import { defineConfig } from 'vite';
import reactRefresh from '@vitejs/plugin-react-refresh';
import { viteVConsole } from 'vite-plugin-vconsole';
import * as path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
reactRefresh(),
viteVConsole({
entry: path.resolve('src/main.tsx'),
enabled: true,
config: {
maxLogNumber: 1000,
theme: 'dark'
}
})
]
});
// Different from the production environment and development environment
// You can use command / mode to distinguish usage
import { UserConfigExport, ConfigEnv } from 'vite';
import { viteVConsole } from 'vite-plugin-vconsole';
import vue from '@vitejs/plugin-vue';
import * as path from 'path'
export default ({ command, mode }: ConfigEnv): UserConfigExport => {
return {
plugins: [
vue(),
viteVConsole({
entry: [path.resolve('src/main.ts')], // entry file
enabled: command !== 'serve' || mode === 'test', // build production
config: { // vconsole options
maxLogNumber: 1000,
theme: 'light'
}
})
],
};
};
viteVConsole({
entry: path.resolve('src/main.ts'),
enabled: true,
config: {
theme: 'dark',
onReady() {
console.log(23333);
}
},
plugin: [
{
id: 'my_plugin',
name: 'MyPlugin',
event: [
{
eventName: 'init',
callback: function () {
console.log('My plugin init');
}
},
{
eventName: 'renderTab',
callback: function () {
console.log('My plugin renderTab');
}
}
]
},
{
id: 'my_plugin2',
name: 'MyPlugin2',
event: [
{
eventName: 'init',
callback: function () {
console.log('My plugin2 init');
}
},
{
eventName: 'renderTab',
callback: function () {
console.log('My plugin2 renderTab');
}
}
]
}
]
})
/// <reference types="vconsole" />
{
entry: string | string[]; // entry file require
enabled?: boolean;
config?: VConsoleOptions
plugin?: {
id: string;
name: string;
event: {
eventName: string;
callback: (data?: any) => void;
}[]
}[]
}
// customHide: A piece of executable code, used to start some APIs on the browser side.
viteVConsole({
entry: path.resolve('src/main.ts'),
enabled: true,
customHide: `/chrome\\/([\\d\\.]+)/.test(navigator.userAgent.toLowerCase())`,
config: {
theme: 'dark',
onReady() {
console.log(23333);
}
},
})
type: string | string[]
require:
must support. Supports multiple entries when it is an array.
type: boolean
default: true
type:: VConsoleOptions
type:
{
id: string;
name: string;
event: {
eventName: string;
callback: (data?: any) => void;
}[]
}[]
type:: String
Add a reference to vconsole
/// <reference types="vconsole" />
Update to V1.1.1+ version, Now you can use it normally in Windows.
Update to V1.2.0+ version, can support multi-page configuration.
Many thanks to @AfireHong for support!
Update to V1.3.0+ version, can support VConsole Functions Configuration.
Many thanks to @KeJunMao for support!
Update to V2.0.0+ version, can support VConsole Plugin Configuration.Also supports custom destruction.
FAQs
vite plugin vconsole
We found that vite-plugin-ssr-vconsole demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.