Skip to content

Commit 8bf0987

Browse files
committedDec 9, 2020
fix(bundler-webpack): display localhost by default in console
1 parent 8340797 commit 8bf0987

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

Diff for: ‎packages/@vuepress/bundler-webpack/src/dev/createDev.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const createDev = (options: WebpackBundlerOptions): BundlerDev => async (
1919
// resolve host and port
2020
const host = app.options.host
2121
const port = await resolvePort(app.options.port)
22-
const url = `http://${host}:${port}${app.options.base}`
2322

2423
// create webpack config
2524
const config = createDevConfig(app, options)
@@ -75,7 +74,14 @@ export const createDev = (options: WebpackBundlerOptions): BundlerDev => async (
7574
return reject(err)
7675
}
7776

78-
logger.success(`VuePress dev server is listening at ${chalk.cyan(url)}`)
77+
// print url in console
78+
// replace `0.0.0.0` with `localhost` as `0.0.0.0` is not available on windows
79+
const url = `http://${host === '0.0.0.0' ? 'localhost' : host}:${port}${
80+
app.options.base
81+
}`
82+
logger.success(
83+
`VuePress webpack dev server is listening at ${chalk.cyan(url)}`
84+
)
7985

8086
// promisify the close function
8187
const close = (): Promise<void> =>

0 commit comments

Comments
 (0)