Skip to content

Commit 2c8f421

Browse files
authored
Merge pull request #151 from xuxichen/vConsole-Configuring
feat: enable vConsole based on environment variable
2 parents 92e4c04 + b2e79ef commit 2c8f421

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ VITE_APP_PUBLIC_PATH=/
22
VITE_APP_PREVIEW=true
33
VITE_APP_API_BASE_URL=/api
44
VITE_APP_OUT_DIR=dist
5+
VITE_APP_VCONSOLE=false

build/vite/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function createVitePlugins(mode: string) {
8888
UnoCSS(),
8989

9090
// https://github.com/vadxq/vite-plugin-vconsole
91-
createViteVConsole(),
91+
createViteVConsole(mode),
9292

9393
// https://github.com/vuejs/devtools-next
9494
VueDevTools(),

build/vite/vconsole.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import path from 'node:path'
2+
import process from 'node:process'
3+
import { loadEnv } from 'vite'
24
import { viteVConsole } from 'vite-plugin-vconsole'
35

4-
export function createViteVConsole() {
6+
export function createViteVConsole(mode: string) {
7+
const env = loadEnv(mode, process.cwd())
58
return viteVConsole({
69
entry: [path.resolve('src/main.ts')],
7-
enabled: false,
10+
enabled: env.VITE_APP_VCONSOLE === 'true',
811
config: {
912
maxLogNumber: 1000,
1013
theme: 'light',

0 commit comments

Comments
 (0)