提交 4d5c50e4 编写于 作者: E Evan You

fix: default to localhost on windows (close #221)

上级 e680936a
......@@ -73,7 +73,13 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
}
const compiler = webpack(config)
const host = cliOptions.host || options.siteConfig.host || '0.0.0.0'
// webpack-serve hot updates doesn't work properly over 0.0.0.0 on Windows,
// but localhost does not allow visiting over network :/
const defaultHost = process.platform === 'win32' ? 'localhost' : '0.0.0.0'
const host = cliOptions.host || options.siteConfig.host || defaultHost
const displayHost = host === defaultHost && process.platform !== 'win32'
? 'localhost'
: host
portfinder.basePort = cliOptions.port || options.siteConfig.port || 8080
const port = await portfinder.getPortPromise()
......@@ -83,7 +89,7 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
isFirst = false
console.log(
`\n VuePress dev server listening at ${
chalk.cyan(`http://${host === '0.0.0.0' ? 'localhost' : host}:${port}${options.publicPath}`)
chalk.cyan(`http://${displayHost}:${port}${options.publicPath}`)
}\n`
)
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册