From 72f93b6ecfb9ffde904a9bc67a933c98c76e46b9 Mon Sep 17 00:00:00 2001 From: Morgan Benton Date: Wed, 30 Dec 2020 17:18:17 -0500 Subject: [PATCH 1/2] add isHttps prop to vuepress-log config Add a property `isHttps` to the options passed to the `DevLogPlugin` used with the `vuepress-log` plugin. The value of this property is determined based on the existence and value of the `devServer.https` property which in turn is part of the `webpack-dev-server` instance used by Vuepress for running a Vuepress site in development mode --- packages/@vuepress/core/lib/node/dev/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/@vuepress/core/lib/node/dev/index.js b/packages/@vuepress/core/lib/node/dev/index.js index 224de1707a..0fb08d6783 100644 --- a/packages/@vuepress/core/lib/node/dev/index.js +++ b/packages/@vuepress/core/lib/node/dev/index.js @@ -175,7 +175,8 @@ module.exports = class DevProcess extends EventEmitter { port: this.port, displayHost: this.displayHost, publicPath: this.context.base, - clearScreen: !(this.context.options.debug || !this.context.options.clearScreen) + clearScreen: !(this.context.options.debug || !this.context.options.clearScreen), + isHttps: (this.context.siteConfig.devServer || {}).https }]) config = config.toConfig() From 39896c26f2035f0adc6c2a938089c44803f85a66 Mon Sep 17 00:00:00 2001 From: Morgan Benton Date: Wed, 30 Dec 2020 17:19:49 -0500 Subject: [PATCH 2/2] conditionally set displayUrl to https Originally, the `displayUrl` output in log messages was hard-coded to be `http`. Now it is set to `https` if the `isHttps` value passed in via `options` is truthy. --- packages/@vuepress/core/lib/node/webpack/DevLogPlugin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@vuepress/core/lib/node/webpack/DevLogPlugin.js b/packages/@vuepress/core/lib/node/webpack/DevLogPlugin.js index 1c9c4af5c9..97feefa7ce 100644 --- a/packages/@vuepress/core/lib/node/webpack/DevLogPlugin.js +++ b/packages/@vuepress/core/lib/node/webpack/DevLogPlugin.js @@ -17,7 +17,7 @@ module.exports = class DevLogPlugin { apply (compiler) { let isFirst = true - const { displayHost, port, publicPath, clearScreen: shouldClearScreen } = this.options + const { displayHost, port, publicPath, clearScreen: shouldClearScreen, isHttps } = this.options compiler.hooks.done.tap('vuepress-log', stats => { if (shouldClearScreen) { @@ -25,7 +25,7 @@ module.exports = class DevLogPlugin { } const time = new Date().toTimeString().match(/^[\d:]+/)[0] - const displayUrl = `http://${displayHost}:${port}${publicPath}` + const displayUrl = `http${isHttps ? 's' : ''}://${displayHost}:${port}${publicPath}` logger.success( `${chalk.gray(`[${time}]`)} Build ${chalk.italic(stats.hash.slice(0, 6))} `