Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

jump to editor source code while click the element of browser automatically.

License

NotificationsYou must be signed in to change notification settings

webfansplz/vite-plugin-vue-inspector

Repository files navigation

vite-plugin-vue-inspector

NPM VersionNPM DownloadsLicense

📖 Introduction

A vite plugin which provides the ability that to jump to the local IDE when you click the element of browser automatically. It supports Vue2 & 3 & SSR.

vite-plugin-vue-inspector

📦 Installation

# vite-plugin-vue-inspectorpnpm install vite-plugin-vue-inspector -D# unplugin-vue-inspectorpnpm install unplugin-vue-inspector -D

🦄 Usage

Configuration Vite

// for Vue2import{defineConfig,}from'vite'import{createVuePlugin,}from'vite-plugin-vue2'importInspectorfrom'unplugin-vue-inspector/vite'// OR vite-plugin-vue-inspectorexportdefaultdefineConfig({plugins:[createVuePlugin(),Inspector({vue:2}),],})
// for Vue3import{defineConfig}from'vite'importVuefrom'@vitejs/plugin-vue'importInspectorfrom'unplugin-vue-inspector/vite'// OR vite-plugin-vue-inspectorexportdefaultdefineConfig({plugins:[Vue(),Inspector()],})
// for Nuxt3// nuxt.config.tsimport{defineNuxtConfig}from'nuxt/config'importInspectorfrom'vite-plugin-vue-inspector'exportdefaultdefineNuxtConfig({modules:[['unplugin-vue-inspector/nuxt',{enabled:true,toggleButtonVisibility:'always',}],],})

Options

interfaceVitePluginInspectorOptions{/**   * Vue version   *@default 3   */vue?:2|3/**   * Default enable state   *@default false   */enabled?:boolean/**   * Define a combo key to toggle inspector   *@default 'control-shift' on windows, 'meta-shift' on other os   *   * any number of modifiers `control` `shift` `alt` `meta` followed by zero or one regular key, separated by -   * examples: control-shift, control-o, control-alt-s  meta-x control-meta   * Some keys have native behavior (e.g. alt-s opens history menu on firefox).   * To avoid conflicts or accidentally typing into inputs, modifier only combinations are recommended.   * You can also disable it by setting `false`.   */toggleComboKey?:string|false/**   * Toggle button visibility   *@default 'active'   */toggleButtonVisibility?:'always'|'active'|'never'/**   * Toggle button display position   *@default top-right   */toggleButtonPos?:'top-right'|'top-left'|'bottom-right'|'bottom-left'/**   * append an import to the module id ending with `appendTo` instead of adding a script into body   * useful for frameworks that do not support transformIndexHtml hook (e.g. Nuxt3)   *   * WARNING: only set this if you know exactly what it does.   */appendTo?:string|RegExp/**   * Customize openInEditor host (e.g. http://localhost:3000)   *@default false   *@deprecated This option is deprecated and removed in 5.0. The plugin now automatically detects the correct host.   */openInEditorHost?:string|false/**   * lazy load inspector times (ms)   *@default false   */lazyLoad?:number|false/**   * disable inspector on editor open   *@default false   */disableInspectorOnEditorOpen?:boolean/**   * Hide information in VNode and produce clean html in DevTools   *   * Currently, it only works for Vue 3   *   *@default true   */cleanHtml?:boolean/**   * Target editor when open in editor (v5.1.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'|'cursor'}

Example

Supported editors

ValueEditorLinuxWindowsOSX
appcodeAppCode
atomAtom
atom-betaAtom Beta
bracketsBrackets
clionClion
codeVisual Studio Code
code-insidersVisual Studio Code Insiders
codiumVSCodium
emacsEmacs
ideaIDEA
notepad++Notepad++
pycharmPyCharm
phpstormPhpStorm
rubymineRubyMine
sublimeSublime Text
vimVim
visualstudioVisual Studio
webstormWebStorm
cursorCursor

🔌 Configuration IDE / Editor

Starting from v5.1.0, We recommend using thelaunchEditor option configuration to specify the IDE (Please ensure that the editor's environment variables are correctly configured beforehand.)

It uses anenvironment variable namedLAUNCH_EDITOR to specify an IDE application, but if you do not set this variable, it will try to open a common IDE that you have open or installed once it is certified.

For example, if you want it always open VS Code when inspection clicked, setexport LAUNCH_EDITOR=code in your shell.

VS Code

  • install VS Code command line tools,see the official docsinstall-vscode-cli

  • set env to shell, like.bashrc or.zshrc

    export LAUNCH_EDITOR=code

VS Code with WSL (Windows)

  • add the configuration in thesettings.json

  • restart the VS Code (All Windows should be closed to take effect)

{// other config..."terminal.integrated.env.linux": {"EDITOR":"code"  }}

WebStorm

  • just set env with an absolute path to shell, like.bashrc or.zshrc (only MacOS)

    export LAUNCH_EDITOR='/Applications/WebStorm.app/Contents/MacOS/webstorm'

OR

  • install WebStorm command line tools

  • then set env to shell, like.bashrc or.zshrc

    export LAUNCH_EDITOR=webstorm

PhpStorm

  • just set env with an absolute path to shell, like.bashrc or.zshrc (only MacOS)

    export LAUNCH_EDITOR='/Applications/PhpStorm.app/Contents/MacOS/phpstorm'

OR

  • install PhpStorm command line tools

  • then set env to shell, like.bashrc or.zshrc

    export LAUNCH_EDITOR=phpstorm

Vim

Yes! you can also use vim if you want, just set env to shell

export LAUNCH_EDITOR=vim

💡 Notice

  • [BREAKING CHANGE] From v1.0,enabled option default value changed fromtrue tofalse .
  • It only work in develop mode .
  • It does not currently supportTemplate Engine (e.g. pug) .

👨‍💻 Programmatic Usage

You can also use control inspector programmatically, by accessing the__VUE_INSPECTOR__ global variable.

importtype{VueInspectorClient}from'vite-plugin-vue-inspector'constinspector:VueInspectorClient=window.__VUE_INSPECTOR__if(inspector){// enable inspectorinspector.enable()// orinspector.disable()}

🌸 Credits

This project is inspired byreact-dev-inspector .

Partially implementation is inspired byvite-plugin-svelte-inspector .

🤖️ Analysis of Theory

[Chinese]点击页面元素,这个Vite插件帮我打开了Vue组件

📄 License

MIT LICENSE

About

jump to editor source code while click the element of browser automatically.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors24


[8]ページ先頭

©2009-2025 Movatter.jp