Skip to content

Commit

Permalink
feat: launchEditor option (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz authored May 8, 2024
1 parent bd49415 commit 7f1476d
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 19 deletions.
20 changes: 19 additions & 1 deletion docs/guide/faq.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
# Frequently Asked Questions

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

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).

## How can I specify the editor for open-in-editor feature?

Starting from **v7.2.0**, you can specify the editor by `launchEditor` option:

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.

```ts
import VueDevTools from 'vite-plugin-vue-devtools'
export default defineConfig({
plugins: [
VueDevTools({
launchEditor: 'webstorm',
}),
Unocss(),
],
})
```

## How to work with Laravel Vite Plugin?

```ts
Expand Down
18 changes: 16 additions & 2 deletions docs/guide/vite-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,28 @@ interface VitePluginVueDevToolsOptions {
appendTo?: string | RegExp

/**
* Customize openInEditor host (e.g. http://localhost:3000)
* Enable vue component inspector
*
* @default true
*/
componentInspector?: boolean | VitePluginInspectorOptions

/**
* Target editor when open in editor (v7.2.0+)
*
* @default code (Visual Studio Code)
*/
launchEditor?: 'appcode' | 'atom' | 'atom-beta' | 'brackets' | 'clion' | 'code' | 'code-insiders' | 'codium' | 'emacs' | 'idea' | 'notepad++' | 'pycharm' | 'phpstorm' | 'rubymine' | 'sublime' | 'vim' | 'visualstudio' | 'webstorm'

/**
* Customize openInEditor host
* @default false
* @deprecated This option is deprecated and removed in 7.1.0. The plugin now automatically detects the correct host.
*/
openInEditorHost?: string | false

/**
* DevTools client host (e.g. http://localhost:3000)
* DevTools client host
* useful for projects that use a reverse proxy
* @default false
* @deprecated This option is deprecated and removed in 7.1.0. The plugin now automatically detects the correct host.
Expand Down
4 changes: 3 additions & 1 deletion packages/playground/basic/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import AutoImport from 'unplugin-auto-import/vite'
export default defineConfig({
plugins: [
vue(),
VueDevTools(),
VueDevTools({
launchEditor: 'code',
}),
Unocss(),
AutoImport({
imports: [
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"execa": "^8.0.1",
"sirv": "^2.0.4",
"vite-plugin-inspect": "^0.8.4",
"vite-plugin-vue-inspector": "^5.0.1"
"vite-plugin-vue-inspector": "^5.1.0"
},
"devDependencies": {
"@types/node": "^20.12.8",
Expand Down
28 changes: 19 additions & 9 deletions packages/vite/src/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,39 @@ export interface VitePluginVueDevToolsOptions {
appendTo?: string | RegExp

/**
* Customize openInEditor host (e.g. http://localhost:3000)
* Enable vue component inspector
*
* @default true
*/
componentInspector?: boolean | VitePluginInspectorOptions

/**
* Target editor when open in editor (v7.2.0+)
*
* @default code (Visual Studio Code)
*/
launchEditor?: 'appcode' | 'atom' | 'atom-beta' | 'brackets' | 'clion' | 'code' | 'code-insiders' | 'codium' | 'emacs' | 'idea' | 'notepad++' | 'pycharm' | 'phpstorm' | 'rubymine' | 'sublime' | 'vim' | 'visualstudio' | 'webstorm'

/**
* Customize openInEditor host
* @default false
* @deprecated This option is deprecated and removed in 7.1.0. The plugin now automatically detects the correct host.
*/
openInEditorHost?: string | false

/**
* DevTools client host (e.g. http://localhost:3000)
* DevTools client host
* useful for projects that use a reverse proxy
* @default false
* @deprecated This option is deprecated and removed in 7.1.0. The plugin now automatically detects the correct host.
*/
clientHost?: string | false

/**
* Enable Vue Component Inspector
*
* @default true
*/
componentInspector?: boolean | VitePluginInspectorOptions
}

const defaultOptions: VitePluginVueDevToolsOptions = {
appendTo: '',
componentInspector: true,
launchEditor: 'code',
}

function mergeOptions(options: VitePluginVueDevToolsOptions): VitePluginVueDevToolsOptions {
Expand Down Expand Up @@ -173,6 +181,7 @@ export default function VitePluginVueDevTools(options?: VitePluginVueDevToolsOpt
pluginOptions.componentInspector && {
tag: 'script',
injectTo: 'head-prepend',
launchEditor: pluginOptions.launchEditor,
attrs: {
type: 'module',
src: `${config.base || '/'}@id/virtual:vue-inspector-path:load.js`,
Expand All @@ -190,6 +199,7 @@ export default function VitePluginVueDevTools(options?: VitePluginVueDevToolsOpt
pluginOptions.componentInspector && VueInspector({
toggleComboKey: '',
toggleButtonVisibility: 'never',
launchEditor: pluginOptions.launchEditor,
...typeof pluginOptions.componentInspector === 'boolean'
? {}
: pluginOptions.componentInspector,
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7f1476d

Please sign in to comment.