diff --git a/bin/vuepress.js b/bin/vuepress.js index c639e858a4..e16c7796f7 100755 --- a/bin/vuepress.js +++ b/bin/vuepress.js @@ -26,8 +26,9 @@ program .command('dev [targetDir]') .description('start development server') .option('-p, --port ', 'use specified port (default: 8080)') - .action((dir = '.', { port }) => { - wrapCommand(dev)(path.resolve(dir), { port }) + .option('-h, --host ', 'use specified host (default: 0.0.0.0)') + .action((dir = '.', { host, port }) => { + wrapCommand(dev)(path.resolve(dir), { host, port }) }) program diff --git a/docs/config/README.md b/docs/config/README.md index 8874407b8e..c29db6917e 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -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` diff --git a/lib/dev.js b/lib/dev.js index 127aac61db..1b6d1b9297 100644 --- a/lib/dev.js +++ b/lib/dev.js @@ -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',