Skip to content

Commit

Permalink
feat: allow configuring host + default to 0.0.0.0 (close #86)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 17, 2018
1 parent 62cd00e commit 9936696
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions bin/vuepress.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ program
.command('dev [targetDir]')
.description('start development server')
.option('-p, --port <port>', 'use specified port (default: 8080)')
.action((dir = '.', { port }) => {
wrapCommand(dev)(path.resolve(dir), { port })
.option('-h, --host <host>', 'use specified host (default: 0.0.0.0)')
.action((dir = '.', { host, port }) => {
wrapCommand(dev)(path.resolve(dir), { host, port })
})

program
Expand Down
7 changes: 7 additions & 0 deletions docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ module.exports = {
}
```

### host

- Type: `string`
- Default: `'0.0.0.0'`

Specify the host to use for the dev server.

### port

- Type: `number`
Expand Down
2 changes: 1 addition & 1 deletion lib/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
// in cwd it would break the server
content: [nonExistentDir],
compiler,
host: process.env.DEBUG ? '0.0.0.0' : 'localhost',
host: cliOptions.host || options.siteConfig.host || '0.0.0.0',
dev: { logLevel: 'warn' },
hot: { logLevel: 'error' },
logLevel: 'error',
Expand Down

0 comments on commit 9936696

Please sign in to comment.