From 99366968f5109f382f493a5e412f5cd5ffe95de7 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 16 Apr 2018 23:43:48 -0400 Subject: [PATCH] feat: allow configuring host + default to 0.0.0.0 (close #86) --- bin/vuepress.js | 5 +++-- docs/config/README.md | 7 +++++++ lib/dev.js | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) 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',