Skip to content

Commit 9936696

Browse files
committed
feat: allow configuring host + default to 0.0.0.0 (close #86)
1 parent 62cd00e commit 9936696

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

bin/vuepress.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ program
2626
.command('dev [targetDir]')
2727
.description('start development server')
2828
.option('-p, --port <port>', 'use specified port (default: 8080)')
29-
.action((dir = '.', { port }) => {
30-
wrapCommand(dev)(path.resolve(dir), { port })
29+
.option('-h, --host <host>', 'use specified host (default: 0.0.0.0)')
30+
.action((dir = '.', { host, port }) => {
31+
wrapCommand(dev)(path.resolve(dir), { host, port })
3132
})
3233

3334
program

docs/config/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ module.exports = {
4949
}
5050
```
5151

52+
### host
53+
54+
- Type: `string`
55+
- Default: `'0.0.0.0'`
56+
57+
Specify the host to use for the dev server.
58+
5259
### port
5360

5461
- Type: `number`

lib/dev.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
9797
// in cwd it would break the server
9898
content: [nonExistentDir],
9999
compiler,
100-
host: process.env.DEBUG ? '0.0.0.0' : 'localhost',
100+
host: cliOptions.host || options.siteConfig.host || '0.0.0.0',
101101
dev: { logLevel: 'warn' },
102102
hot: { logLevel: 'error' },
103103
logLevel: 'error',

0 commit comments

Comments
 (0)