Skip to content

Instantly share code, notes, and snippets.

@moreta
Last active August 19, 2022 07:44
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save moreta/d3989686b6a1f2416b5802cac8df16b4 to your computer and use it in GitHub Desktop.
Save moreta/d3989686b6a1f2416b5802cac8df16b4 to your computer and use it in GitHub Desktop.
Vue devtool Open component in editor tips

More document for "Vue devtool Open component in editor"

Prepare

Visual Studio code

Users on macOS must first run a command (Shell Command: Install 'code' command in PATH) to add VS Code executable to the PATH environment variable. Read the macOS Setup guide for help.

vs shell-command install

webstorm or other jetBrain's editor

First install Command Line Launcher

"Tools" -> "Create Command Line Launcher..."

jetbrain's editor cli install

Webpack

In your Vue project, install the launch-editor-middleware package and modifiy your webpack configuration:

  1. Install the package
yarn add --dev launch-editor-middleware
// or
npm install --save-dev launch-editor-middleware

1. Import the package:

If you use vue-cli's webpack template

in 'build/webpack.dev.conf.js'

const openInEditor = require('launch-editor-middleware')
}

2. In the devServer option, register the /__open-in-editor HTTP route:

in 'build/webpack.dev.conf.js'

devServer: {
  before (app) {
    app.use('/__open-in-editor', openInEditor())
  }
}

3. specify the editor

from https://github.com/vuejs/vue-devtools/blob/master/docs/open-in-editor.md

The editor to launch is guessed. You can also specify the editor app with the editor option. See the supported editors list.

npm launch-editor can specify editor. If you installed visual studio code shell-command, this works!

launch-editor launch just

devServer: {
  before (app) {
    app.use('/__open-in-editor', openInEditor('code'))
  }
}

If you didn't install editor's command-line specify full path.

See : https://github.com/yyx990803/launch-editor/blob/master/packages/launch-editor/editor-info/osx.js

devServer: {
  before (app) {
    app.use('/__open-in-editor', openInEditor('/Applications/WebStorm.app/Contents/MacOS/webstorm'))
  }
}

editor priority

If you open multiple editor, first process editor open.

There are not yet 'specify editor priority' feature in 'launch-editor'.

@moreta
Copy link
Author

moreta commented Jan 22, 2018

jetbrain editor cli install

jetbrain_editor_cli_install

2018-01-22 16 30 40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment