Skip to content

Commit a14550e

Browse files
authored
feat(projects): ✨ support vite devtools specify the editor by launchEditor option.
1 parent e19e94d commit a14550e

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

.env

+5-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,8 @@ VITE_STORAGE_PREFIX=SOY_
5353
VITE_AUTOMATICALLY_DETECT_UPDATE=Y
5454

5555
# show proxy url log in terminal
56-
VITE_PROXY_LOG=Y
56+
VITE_PROXY_LOG=Y
57+
58+
# used to control whether to launch editor
59+
# by the way, this plugin is only available in dev mode, not in build mode
60+
VITE_DEVTOOLS_LAUNCH_EDITOR=code

build/plugins/devtools.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import VueDevtools from 'vite-plugin-vue-devtools';
2+
3+
export function setupDevtoolsPlugin(viteEnv: Env.ImportMeta) {
4+
const { VITE_DEVTOOLS_LAUNCH_EDITOR } = viteEnv;
5+
6+
return VueDevtools({
7+
launchEditor: VITE_DEVTOOLS_LAUNCH_EDITOR
8+
});
9+
}

build/plugins/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import type { PluginOption } from 'vite';
22
import vue from '@vitejs/plugin-vue';
33
import vueJsx from '@vitejs/plugin-vue-jsx';
4-
import VueDevtools from 'vite-plugin-vue-devtools';
54
import progress from 'vite-plugin-progress';
65
import { setupElegantRouter } from './router';
76
import { setupUnocss } from './unocss';
87
import { setupUnplugin } from './unplugin';
98
import { setupHtmlPlugin } from './html';
9+
import { setupDevtoolsPlugin } from './devtools';
1010

1111
export function setupVitePlugins(viteEnv: Env.ImportMeta, buildTime: string) {
1212
const plugins: PluginOption = [
1313
vue(),
1414
vueJsx(),
15-
VueDevtools(),
15+
setupDevtoolsPlugin(viteEnv),
1616
setupElegantRouter(),
1717
setupUnocss(viteEnv),
1818
...setupUnplugin(viteEnv),

src/typings/vite-env.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ declare namespace Env {
106106
readonly VITE_STORAGE_PREFIX?: string;
107107
/** Whether to automatically detect updates after configuring application packaging */
108108
readonly VITE_AUTOMATICALLY_DETECT_UPDATE?: CommonType.YesOrNo;
109+
/** show proxy url log in terminal */
110+
readonly VITE_PROXY_LOG?: CommonType.YesOrNo;
111+
/** The launch editor */
112+
readonly VITE_DEVTOOLS_LAUNCH_EDITOR?: import('vite-plugin-vue-devtools').VitePluginVueDevToolsOptions['launchEditor'];
109113
}
110114
}
111115

0 commit comments

Comments
 (0)