Skip to content

Commit be814b3

Browse files
ykztshaoqunjiang
authored andcommitted
feat(ui): add --host option (#2568)
1 parent 0e5cf4a commit be814b3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/@vue/cli/bin/vue.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ program
115115
program
116116
.command('ui')
117117
.description('start and open the vue-cli ui')
118+
.option('-H, --host <host>', 'Host used for the UI server (default: localhost)')
118119
.option('-p, --port <port>', 'Port used for the UI server (by default search for available port)')
119120
.option('-D, --dev', 'Run in dev mode')
120121
.option('--quiet', `Don't output starting messages`)

packages/@vue/cli/lib/ui.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const { portfinder, server } = require('@vue/cli-ui/server')
33
const shortid = require('shortid')
44

55
async function ui (options = {}, context = process.cwd()) {
6+
const host = options.host || 'localhost'
7+
68
let port = options.port
79
if (!port) {
810
port = await portfinder.getPortPromise()
@@ -28,6 +30,7 @@ async function ui (options = {}, context = process.cwd()) {
2830
if (!options.quiet) log(`🚀 Starting GUI...`)
2931

3032
const opts = {
33+
host,
3134
port,
3235
graphqlPath: '/graphql',
3336
subscriptionsPath: '/graphql',
@@ -55,7 +58,7 @@ async function ui (options = {}, context = process.cwd()) {
5558
}
5659

5760
// Open browser
58-
const url = `http://localhost:${port}`
61+
const url = `http://${host}:${port}`
5962
if (!options.quiet) log(`🌠 Ready on ${url}`)
6063
if (options.headless) {
6164
console.log(port)

0 commit comments

Comments
 (0)