From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/vuepress/lib/webpack/DevLogPlugin.js | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 node_modules/vuepress/lib/webpack/DevLogPlugin.js (limited to 'node_modules/vuepress/lib/webpack/DevLogPlugin.js') diff --git a/node_modules/vuepress/lib/webpack/DevLogPlugin.js b/node_modules/vuepress/lib/webpack/DevLogPlugin.js new file mode 100644 index 00000000..8fd18d4a --- /dev/null +++ b/node_modules/vuepress/lib/webpack/DevLogPlugin.js @@ -0,0 +1,38 @@ +const chalk = require('chalk') +const logger = require('../util/logger') + +module.exports = class DevLogPlugin { + constructor (options) { + this.options = options + } + + apply (compiler) { + let isFirst = true + compiler.hooks.done.tap('vuepress-log', stats => { + clearScreen() + + 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! ` + + ( + isFirst + ? '' + : `${chalk.gray(`(${displayUrl})`)}` + ) + ) + if (isFirst) { + isFirst = false + console.log(`\n${chalk.gray('>')} VuePress dev server listening at ${chalk.cyan(displayUrl)}`) + } + }) + compiler.hooks.invalid.tap('vuepress-log', clearScreen) + } +} + +function clearScreen () { + process.stdout.write('\x1Bc') +} -- cgit v1.2.3