Skip to content

Commit 7f1476d

Browse files
authoredMay 8, 2024··
feat: launchEditor option (#373)
1 parent bd49415 commit 7f1476d

File tree

6 files changed

+63
-19
lines changed

6 files changed

+63
-19
lines changed
 

Diff for: ‎docs/guide/faq.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
# Frequently Asked Questions
22

3-
## I can't use the Open In Editor feature
3+
## I can't use the open-in-editor feature
44

55
The feature is based on the [vite-plugin-vue-inspector](https://github.com/webfansplz/vite-plugin-vue-inspector) plugin and requires configuration, which you can do by looking at the [configuration documentation](https://github.com/webfansplz/vite-plugin-vue-inspector?tab=readme-ov-file#--configuration-ide--editor).
66

7+
## How can I specify the editor for open-in-editor feature?
8+
9+
Starting from **v7.2.0**, you can specify the editor by `launchEditor` option:
10+
11+
This is a list of [supported editors](https://github.com/yyx990803/launch-editor?tab=readme-ov-file#supported-editors), please ensure that the editor's environment variables are correctly configured beforehand.
12+
13+
```ts
14+
import VueDevTools from 'vite-plugin-vue-devtools'
15+
export default defineConfig({
16+
plugins: [
17+
VueDevTools({
18+
launchEditor: 'webstorm',
19+
}),
20+
Unocss(),
21+
],
22+
})
23+
```
24+
725
## How to work with Laravel Vite Plugin?
826

927
```ts

Diff for: ‎docs/guide/vite-plugin.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,28 @@ interface VitePluginVueDevToolsOptions {
5757
appendTo?: string | RegExp
5858

5959
/**
60-
* Customize openInEditor host (e.g. http://localhost:3000)
60+
* Enable vue component inspector
61+
*
62+
* @default true
63+
*/
64+
componentInspector?: boolean | VitePluginInspectorOptions
65+
66+
/**
67+
* Target editor when open in editor (v7.2.0+)
68+
*
69+
* @default code (Visual Studio Code)
70+
*/
71+
launchEditor?: 'appcode' | 'atom' | 'atom-beta' | 'brackets' | 'clion' | 'code' | 'code-insiders' | 'codium' | 'emacs' | 'idea' | 'notepad++' | 'pycharm' | 'phpstorm' | 'rubymine' | 'sublime' | 'vim' | 'visualstudio' | 'webstorm'
72+
73+
/**
74+
* Customize openInEditor host
6175
* @default false
6276
* @deprecated This option is deprecated and removed in 7.1.0. The plugin now automatically detects the correct host.
6377
*/
6478
openInEditorHost?: string | false
6579

6680
/**
67-
* DevTools client host (e.g. http://localhost:3000)
81+
* DevTools client host
6882
* useful for projects that use a reverse proxy
6983
* @default false
7084
* @deprecated This option is deprecated and removed in 7.1.0. The plugin now automatically detects the correct host.

Diff for: ‎packages/playground/basic/vite.config.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import AutoImport from 'unplugin-auto-import/vite'
99
export default defineConfig({
1010
plugins: [
1111
vue(),
12-
VueDevTools(),
12+
VueDevTools({
13+
launchEditor: 'code',
14+
}),
1315
Unocss(),
1416
AutoImport({
1517
imports: [

Diff for: ‎packages/vite/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"execa": "^8.0.1",
5757
"sirv": "^2.0.4",
5858
"vite-plugin-inspect": "^0.8.4",
59-
"vite-plugin-vue-inspector": "^5.0.1"
59+
"vite-plugin-vue-inspector": "^5.1.0"
6060
},
6161
"devDependencies": {
6262
"@types/node": "^20.12.8",

Diff for: ‎packages/vite/src/vite.ts

+19-9
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,39 @@ export interface VitePluginVueDevToolsOptions {
4242
appendTo?: string | RegExp
4343

4444
/**
45-
* Customize openInEditor host (e.g. http://localhost:3000)
45+
* Enable vue component inspector
46+
*
47+
* @default true
48+
*/
49+
componentInspector?: boolean | VitePluginInspectorOptions
50+
51+
/**
52+
* Target editor when open in editor (v7.2.0+)
53+
*
54+
* @default code (Visual Studio Code)
55+
*/
56+
launchEditor?: 'appcode' | 'atom' | 'atom-beta' | 'brackets' | 'clion' | 'code' | 'code-insiders' | 'codium' | 'emacs' | 'idea' | 'notepad++' | 'pycharm' | 'phpstorm' | 'rubymine' | 'sublime' | 'vim' | 'visualstudio' | 'webstorm'
57+
58+
/**
59+
* Customize openInEditor host
4660
* @default false
4761
* @deprecated This option is deprecated and removed in 7.1.0. The plugin now automatically detects the correct host.
4862
*/
4963
openInEditorHost?: string | false
5064

5165
/**
52-
* DevTools client host (e.g. http://localhost:3000)
66+
* DevTools client host
5367
* useful for projects that use a reverse proxy
5468
* @default false
5569
* @deprecated This option is deprecated and removed in 7.1.0. The plugin now automatically detects the correct host.
5670
*/
5771
clientHost?: string | false
58-
59-
/**
60-
* Enable Vue Component Inspector
61-
*
62-
* @default true
63-
*/
64-
componentInspector?: boolean | VitePluginInspectorOptions
6572
}
6673

6774
const defaultOptions: VitePluginVueDevToolsOptions = {
6875
appendTo: '',
6976
componentInspector: true,
77+
launchEditor: 'code',
7078
}
7179

7280
function mergeOptions(options: VitePluginVueDevToolsOptions): VitePluginVueDevToolsOptions {
@@ -173,6 +181,7 @@ export default function VitePluginVueDevTools(options?: VitePluginVueDevToolsOpt
173181
pluginOptions.componentInspector && {
174182
tag: 'script',
175183
injectTo: 'head-prepend',
184+
launchEditor: pluginOptions.launchEditor,
176185
attrs: {
177186
type: 'module',
178187
src: `${config.base || '/'}@id/virtual:vue-inspector-path:load.js`,
@@ -190,6 +199,7 @@ export default function VitePluginVueDevTools(options?: VitePluginVueDevToolsOpt
190199
pluginOptions.componentInspector && VueInspector({
191200
toggleComboKey: '',
192201
toggleButtonVisibility: 'never',
202+
launchEditor: pluginOptions.launchEditor,
193203
...typeof pluginOptions.componentInspector === 'boolean'
194204
? {}
195205
: pluginOptions.componentInspector,

Diff for: ‎pnpm-lock.yaml

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.