Skip to content

Commit 86b386a

Browse files
author
Guillaume Chau
committed
Merge remote-tracking branch 'upstream/master'
2 parents 24749d4 + 4994856 commit 86b386a

File tree

4 files changed

+50
-6
lines changed

4 files changed

+50
-6
lines changed

Diff for: shells/electron/README.md

+44-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ Then add:
3131
Or if you want to debug your device remotely:
3232
```html
3333
<script>
34-
window.__VUE_DEVTOOLS_HOST__ = '<your-local-ip>'
34+
window.__VUE_DEVTOOLS_HOST__ = '<your-local-ip>' // default: localhost
35+
window.__VUE_DEVTOOLS_PORT__ = '<devtools-port>' // default: 8098
3536
</script>
3637
<script src="http://<your-local-ip>:8098"></script>
3738
```
@@ -60,12 +61,53 @@ import devtools from '@vue/devtools'
6061
And connect to host:
6162
```js
6263
if (process.env.NODE_ENV === 'development') {
63-
devtools.connect(/* host */)
64+
devtools.connect(/* host, port */)
6465
}
6566
```
6667

6768
**host** - is an optional argument that tells your application where devtools middleware server is running, if you debug you app on your computer you don't have to set this (the default is `http://localhost`), but if you want to debug your app on mobile devices, you might want to pass your local IP (e.g. `192.168.1.12`).
6869

70+
**port** - is an optional argument that tells your application on what port devtools middleware server is running. If you use proxy server, you might want to set it to `null` so the port won't be added to connection URL.
71+
72+
#### FAQ:
73+
74+
**1. How to change port devtools server is running on?**
75+
76+
You can change it by setting environment variable before running it:
77+
```
78+
PORT=8000 vue-devtools
79+
```
80+
81+
Then in your app you'll have to set either:
82+
```
83+
window.__VUE_DEVTOOLS_PORT__ = 8000
84+
```
85+
86+
Or update connect method with new port:
87+
```
88+
devtools.connect(/* host */, 8000)
89+
```
90+
91+
**2. How to remotely inspect page on the server?**
92+
93+
For that you can use `ngrok` proxy. You can download it [here](https://ngrok.com/).
94+
95+
Once you start vue-devtools run:
96+
```
97+
ngrok http 8098
98+
```
99+
100+
Then update your host and port accordingly:
101+
```
102+
devtools.connect('example.ngrok.io', null)
103+
```
104+
105+
Make sure to set port to `null` or `false`, because ngrok host already proxies to proper port that we defined in the first command.
106+
107+
**3. How to inspect page served through `HTTPS`?**
108+
109+
For that you can also use ngrok, as it automatically proxies https requests to http. Take a look at question number 2 for instructions.
110+
69111
### :beers: Development
70112

71113
1. Install all dependencies

Diff for: shells/electron/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
require('./build/hook.js')
22

33
module.exports = {
4-
connect: function (host) {
4+
connect: function (host, port) {
55
window.__VUE_DEVTOOLS_HOST__ = host
6+
window.__VUE_DEVTOOLS_PORT__ = port
67
require('./build/backend.js')
78
}
89
}

Diff for: shells/electron/src/backend.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import Bridge from 'src/bridge'
44
import { installToast } from 'src/backend/toast'
55

66
const host = window.__VUE_DEVTOOLS_HOST__ || 'http://localhost'
7-
const port = process.env.PORT || 8098
8-
const socket = io(host + ':' + port)
7+
const port = window.__VUE_DEVTOOLS_PORT__ !== undefined ? window.__VUE_DEVTOOLS_PORT__ : 8098
8+
const fullHost = port ? host + ':' + port : host
9+
const socket = io(fullHost)
910

1011
const connectedMessage = () => {
1112
if (window.__VUE_DEVTOOLS_TOAST__) {

Diff for: shells/electron/src/devtools.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import io from 'socket.io-client'
22
import { initDevTools } from 'src/devtools'
33
import Bridge from 'src/bridge'
44

5-
const port = process.env.PORT || 8098
5+
const port = window.process.env.PORT || 8098
66
const socket = io('http://localhost:' + port)
77
const $ = document.querySelector.bind(document)
88
const $intro = $('#intro')

0 commit comments

Comments
 (0)