Skip to content

Commit

Permalink
feat($webpack): display host url at dev HMR log
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Aug 8, 2018
1 parent 12c2beb commit 2e8d69c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/webpack/DevLogPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2e8d69c

Please sign in to comment.