mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-07 12:48:30 +08:00
29 lines
664 B
TypeScript
29 lines
664 B
TypeScript
import type { Plugin } from 'vite'
|
|
|
|
export default function createDebugTool(env): Plugin {
|
|
const { VITE_APP_DEBUG_TOOL } = env
|
|
return {
|
|
name: 'debug-plugin',
|
|
transform: (code, id) => {
|
|
if (/src\/main.ts$/.test(id)) {
|
|
if (VITE_APP_DEBUG_TOOL === 'eruda') {
|
|
code = code.concat(`
|
|
import eruda from 'eruda'
|
|
eruda.init()
|
|
`)
|
|
}
|
|
else if (VITE_APP_DEBUG_TOOL === 'vconsole') {
|
|
code = code.concat(`
|
|
import VConsole from 'vconsole'
|
|
new VConsole()
|
|
`)
|
|
}
|
|
return {
|
|
code,
|
|
map: null,
|
|
}
|
|
}
|
|
},
|
|
}
|
|
}
|