mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-07 16:18:19 +08:00
23 lines
524 B
TypeScript
23 lines
524 B
TypeScript
import type { Plugin } from 'vite'
|
|
|
|
export default function createDisableDevtool(env): Plugin {
|
|
const { VITE_APP_DISABLE_DEVTOOL } = env
|
|
return {
|
|
name: 'disable-devtool',
|
|
transform: (code, id) => {
|
|
if (/src\/main.ts$/.test(id)) {
|
|
if (VITE_APP_DISABLE_DEVTOOL === 'true') {
|
|
code = code.concat(`
|
|
import DisableDevtool from 'disable-devtool'
|
|
DisableDevtool()
|
|
`)
|
|
}
|
|
return {
|
|
code,
|
|
map: null,
|
|
}
|
|
}
|
|
},
|
|
}
|
|
}
|