VuePress:如何在dev服务器中使用https?

VuePress:如何在dev服务器中使用https?,https,vuepress,Https,Vuepress,VuePress dev服务器中是否有启用https的钩子 1.当前解决方案。 我直接在node_modules/@vuepress/core/lib/node/dev/index.js中添加了一行代码。这很有效,但很糟糕 createServer () { const contentBase = path.resolve(this.context.sourceDir, '.vuepress/public') const serverConfig = Object.assi

VuePress dev服务器中是否有启用https的钩子

1.当前解决方案。 我直接在node_modules/@vuepress/core/lib/node/dev/index.js中添加了一行代码。这很有效,但很糟糕

  createServer () {
    const contentBase = path.resolve(this.context.sourceDir, '.vuepress/public')

    const serverConfig = Object.assign({

      https: true, // <--- Added this line.

      disableHostCheck: true,
      compress: true,
      clientLogLevel: 'error',

  • 没有合适的挂钩

  • 没有https的命令选项

module.exports=函数(cli,选项){
cli
.command(`dev[targetDir]`,‘启动开发服务器’)
.选项('-p,--port','使用指定的端口(默认值:8080)')
.option('-t,--temp','设置临时文件的目录')
.option('-c,--cache[cache]','set the directory of cache')
.选项(“--host”,“使用指定的主机(默认值:0.0.0.0)”)
.option(“--no cache”,“在生成之前清理缓存”)
.option(“--no clear screen”,“在开发服务器准备就绪时不清除屏幕”)
.option(“--debug”,“在调试模式下启动开发服务器”)
.option(“--silent”,“在silent模式下启动开发服务器”)
.选项(“--open”,“准备就绪时打开浏览器”)
.action((sourceDir='.',commandOptions)=>{
const{debug,silent}=commandOptions
4.相关链接。

将以下设置添加到
config.js

//
//docs/.vuepress/config.js
//
module.exports={
开发服务器:{
https:对
},
}

在许多方面感谢您的指导。

将以下设置添加到
config.js

//
//docs/.vuepress/config.js
//
module.exports={
开发服务器:{
https:对
},
}

感谢您在许多方面给予的指导。

欢迎来到StackOverflow社区!您似乎已经尝试过设置问题的格式,至少您已经尝试过了。请阅读本文()这将有助于你将来处理降价。别忘了投票给那些为你的问题提供有用信息的用户,并将其标记为已解决。先生,请抄写:)检查此问题,将帮助您:Gabriel Willemann,感谢您的指导。欢迎来到StackOverflow社区!似乎您已经尝试自己设置问题的格式,至少您尝试过了。请阅读本文()这将有助于你将来处理降价。别忘了投票给那些为你的问题提供有用信息的用户,并将其标记为已解决。先生:)请复制,检查这个问题,将有助于你:Gabriel Willemann,谢谢你的指导。
  configureWebpack: (config, isServer) => {
    if (!config.devServer) {
      config.devServer = {}
    }
    Object.assign(config.devServer, {
      https: true,
    })
  }
module.exports = function (cli, options) {
  cli
    .command(`dev [targetDir]`, 'start development server')
    .option('-p, --port <port>', 'use specified port (default: 8080)')
    .option('-t, --temp <temp>', 'set the directory of the temporary file')
    .option('-c, --cache [cache]', 'set the directory of cache')
    .option('--host <host>', 'use specified host (default: 0.0.0.0)')
    .option('--no-cache', 'clean the cache before build')
    .option('--no-clear-screen', 'do not clear screen when dev server is ready')
    .option('--debug', 'start development server in debug mode')
    .option('--silent', 'start development server in silent mode')
    .option('--open', 'open browser when ready')
    .action((sourceDir = '.', commandOptions) => {
      const { debug, silent } = commandOptions