Commit 764f1fb4841bdebdc4bfc288fd7a4d254cd60f10
1 parent
35cee7d7
perf: add user config in dropConsoleInVue3VideoPlay vite plugin
Showing
1 changed file
with
8 additions
and
5 deletions
1 | import { Plugin } from 'vite'; | 1 | import { Plugin } from 'vite'; |
2 | 2 | ||
3 | -export function dropConsoleInVue3VideoPlayPlugin() { | 3 | +export function dropConsoleInVue3VideoPlayPlugin(params?: { enabled: boolean }) { |
4 | + const { enabled = true } = params || {}; | ||
4 | return { | 5 | return { |
5 | name: 'drop-console-in-vue3-video-play-plugin', | 6 | name: 'drop-console-in-vue3-video-play-plugin', |
6 | transform(src, id) { | 7 | transform(src, id) { |
7 | - if (id.includes('vue3-video-play')) { | ||
8 | - return { | ||
9 | - code: src.replaceAll('console.log', ''), | ||
10 | - }; | 8 | + if (enabled) { |
9 | + if (id.includes('vue3-video-play')) { | ||
10 | + return { | ||
11 | + code: src.replaceAll('console.log', ''), | ||
12 | + }; | ||
13 | + } | ||
11 | } | 14 | } |
12 | }, | 15 | }, |
13 | } as Plugin; | 16 | } as Plugin; |