Skip to content

Commit

Permalink
Switch to launch-editor-middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Jan 6, 2018
1 parent 3d77274 commit bf13184
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 37 deletions.
20 changes: 12 additions & 8 deletions docs/open-in-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,34 @@ Nuxt supports this feature out-of-the-box. Make sure to be in debug mode.

## Webpack

In your Vue project, install the [express-open-in-editor](https://github.com/lahmatiy/express-open-in-editor) package and modifiy your webpack configuration:
In your Vue project, install the [launch-editor-middleware](https://github.com/yyx990803/launch-editor#middleware) package and modifiy your webpack configuration:

1. Import the package:

```js
var openInEditor = require('express-open-in-editor')
var openInEditor = require('launch-editor-middleware')
```

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

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

3. You can change `'code'` with the editor you are using, see the [supported editors list](https://github.com/lahmatiy/open-in-editor#editor).
3. The editor to launch is guessed. You can also specify the editor app with the `editor` option. See the [supported editors list](https://github.com/lahmatiy/open-in-editor#editor).

You can now click on the name of the component in the Component inspector pane (if the devtools knows about its file source, a tooltip will appear).
```js
openInEditor({
editor: 'code'
})
```

4. You can now click on the name of the component in the Component inspector pane (if the devtools knows about its file source, a tooltip will appear).

## Node.js

You can use the [open-in-editor](https://github.com/lahmatiy/open-in-editor) package to setup an HTTP route with the `/__open-in-editor` path. It will receive `file` as an URL variable.
You can use the [launch-editor](https://github.com/yyx990803/launch-editor#usage) package to setup an HTTP route with the `/__open-in-editor` path. It will receive `file` as an URL variable.
74 changes: 55 additions & 19 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"css-loader": "^0.28.7",
"eslint": "^4.13.1",
"eslint-plugin-vue-libs": "^2.0.1",
"express-open-in-editor": "^3.1.1",
"file-loader": "^1.1.6",
"friendly-errors-webpack-plugin": "^1.6.1",
"launch-editor-middleware": "^1.0.0",
"nightwatch": "^0.9.19",
"nightwatch-helpers": "^1.2.0",
"selenium-server": "2.52.0",
Expand Down
14 changes: 5 additions & 9 deletions shells/dev/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
var path = require('path')
var webpack = require('webpack')
var alias = require('../alias')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
var openInEditor = require('express-open-in-editor')
var openInEditor = require('launch-editor-middleware')

var bubleOptions = {
target: { chrome: 52, firefox: 48 },
Expand All @@ -19,7 +17,7 @@ module.exports = {
output: {
path: __dirname + '/build',
publicPath: '/build/',
filename: '[name].js',
filename: '[name].js'
},
resolve: {
alias
Expand All @@ -28,7 +26,7 @@ module.exports = {
rules: [
{
test: /\.js$/,
loader: 'buble-loader',
loader: 'buble-loader',
exclude: /node_modules|vue\/dist|vuex\/dist/,
options: bubleOptions
},
Expand All @@ -53,10 +51,8 @@ module.exports = {
devServer: {
quiet: true,
before (app) {
app.use('/__open-in-editor', openInEditor({
editor: 'code'
}))
app.use('/__open-in-editor', openInEditor())
}
},
plugins: process.env.VUE_DEVTOOL_TEST ? [] :[new FriendlyErrorsPlugin()]
plugins: process.env.VUE_DEVTOOL_TEST ? [] : [new FriendlyErrorsPlugin()]
}

0 comments on commit bf13184

Please sign in to comment.