From 2e8d69cf2437cc25eb68bb87d81d9e9a77bca997 Mon Sep 17 00:00:00 2001 From: ULIVZ <472590061@qq.com> Date: Wed, 8 Aug 2018 23:29:58 +0800 Subject: [PATCH] feat($webpack): display host url at dev HMR log --- lib/webpack/DevLogPlugin.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/webpack/DevLogPlugin.js b/lib/webpack/DevLogPlugin.js index 8481b54dde..8fd18d4a0a 100644 --- a/lib/webpack/DevLogPlugin.js +++ b/lib/webpack/DevLogPlugin.js @@ -13,11 +13,20 @@ module.exports = class DevLogPlugin { const { displayHost, port, publicPath } = this.options const time = new Date().toTimeString().match(/^[\d:]+/)[0] + const displayUrl = `http://${displayHost}:${port}${publicPath}` - logger.success(`\n${chalk.gray(`[${time}]`)} Build ${chalk.italic(stats.hash.slice(0, 6))} finished in ${stats.endTime - stats.startTime} ms!`) + logger.success( + `\n${chalk.gray(`[${time}]`)} Build ${chalk.italic(stats.hash.slice(0, 6))} ` + + `finished in ${stats.endTime - stats.startTime} ms! ` + + ( + isFirst + ? '' + : `${chalk.gray(`(${displayUrl})`)}` + ) + ) if (isFirst) { isFirst = false - console.log(`\n${chalk.gray('>')} VuePress dev server listening at ${chalk.cyan(`http://${displayHost}:${port}${publicPath}`)}`) + console.log(`\n${chalk.gray('>')} VuePress dev server listening at ${chalk.cyan(displayUrl)}`) } }) compiler.hooks.invalid.tap('vuepress-log', clearScreen)