Skip to content

Commit ca28d0b

Browse files
committed
build(vconsole): vconsole => vite-plugin-vconsole close #9
1 parent 7d9abaf commit ca28d0b

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"umi-mock-middleware2": "^1.0.2",
4949
"unplugin-vue-components": "^0.19.6",
5050
"vite": "^2.9.9",
51+
"vite-plugin-vconsole": "^1.2.2",
5152
"vue-tsc": "^0.34.7"
5253
}
5354
}

src/main.ts

-10
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ import './app.less'
88
// Vant 桌面端适配
99
import '@vant/touch-emulator'
1010

11-
// debugger board
12-
import VConsole from 'vconsole'
13-
new VConsole({ theme: 'light' })
14-
15-
// 结束调试后,可移除掉
16-
// vConsole.destroy()
17-
18-
// vite-plugin-vconsole 社区版
19-
// https://github.com/vadxq/vite-plugin-vconsole
20-
2111
const app = createApp(App)
2212

2313
app

vite.config.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import vueJsx from '@vitejs/plugin-vue-jsx'
44
import type { ConfigEnv, UserConfig } from 'vite'
55
import { visualizer } from 'rollup-plugin-visualizer'
66
import Components from 'unplugin-vue-components/vite'
7+
import { viteVConsole } from 'vite-plugin-vconsole'
78
import { VantResolver } from 'unplugin-vue-components/resolvers'
89
import createMockServer from './build/mockServer'
910
import path from 'path'
1011

1112
// https://vitejs.dev/config/
12-
export default ({ mode }: ConfigEnv): UserConfig => {
13+
export default ({ command, mode }: ConfigEnv): UserConfig => {
1314
const root = process.cwd()
1415
const env = loadEnv(mode, root)
1516
return {
@@ -19,18 +20,23 @@ export default ({ mode }: ConfigEnv): UserConfig => {
1920
'process.env.VUE_APP_PUBLIC_PATH': JSON.stringify(env.VITE_APP_PUBLIC_PATH),
2021
},
2122
plugins: [
22-
vue({
23-
// Reactivity transform is an experimental feature.
24-
// https://github.com/vuejs/rfcs/discussions/369.
25-
// reactivityTransform: true
26-
}),
23+
vue(),
2724
vueJsx(),
2825
visualizer(),
2926
Components({
3027
dts: true,
3128
resolvers: [VantResolver()],
3229
types: [],
3330
}),
31+
viteVConsole({
32+
entry: [path.resolve('src/main.ts')],
33+
localEnabled: command === 'serve',
34+
enabled: false,
35+
config: {
36+
maxLogNumber: 1000,
37+
theme: 'light'
38+
}
39+
})
3440
],
3541
resolve: {
3642
alias: {

yarn.lock

+8-3
Original file line numberDiff line numberDiff line change
@@ -1282,9 +1282,9 @@ copy-text-to-clipboard@^3.0.1:
12821282
integrity sha512-rvVsHrpFcL4F2P8ihsoLdFHmd404+CMg71S756oRSeQgqk51U3kicGdnvfkrxva0xXH92SjGS62B0XIJsbh+9Q==
12831283

12841284
core-js@^3.11.0:
1285-
version "3.22.8"
1286-
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.22.8.tgz#23f860b1fe60797cc4f704d76c93fea8a2f60631"
1287-
integrity sha512-UoGQ/cfzGYIuiq6Z7vWL1HfkE9U9IZ4Ub+0XSiJTCzvbZzgPA69oDF2f+lgJ6dFFLEdjW5O6svvoKzXX23xFkA==
1285+
version "3.23.2"
1286+
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.23.2.tgz#e07a60ca8b14dd129cabdc3d2551baf5a01c76f0"
1287+
integrity sha512-ELJOWxNrJfOH/WK4VJ3Qd+fOqZuOuDNDJz0xG6Bt4mGg2eO/UT9CljCrbqDGovjLKUrGajEEBcoTOc0w+yBYeQ==
12881288

12891289
cross-env@^7.0.3:
12901290
version "7.0.3"
@@ -3968,6 +3968,11 @@ vconsole@^3.14.6:
39683968
core-js "^3.11.0"
39693969
mutation-observer "^1.0.3"
39703970

3971+
vite-plugin-vconsole@^1.2.2:
3972+
version "1.2.2"
3973+
resolved "https://registry.yarnpkg.com/vite-plugin-vconsole/-/vite-plugin-vconsole-1.2.2.tgz#58d96835bf75aa034094febc57798f48fa1b9709"
3974+
integrity sha512-eB0uyQzEQAijpxxcgnE9h/k0y6Lr5wiYeq+OW/4hPT7sNwd4KVqMKQXArTn5S6zy8Uo7ae7ulAU3atczekAGAw==
3975+
39713976
vite@^2.9.9:
39723977
version "2.9.12"
39733978
resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.12.tgz#b1d636b0a8ac636afe9d83e3792d4895509a941b"

0 commit comments

Comments
 (0)