[英]VuePress: How can I use https in dev server?
Is there any hook to enable https in VuePress dev server?在 VuePress 开发服务器中启用 https 是否有任何挂钩?
I directly add one line to node_modules/@vuepress/core/lib/node/dev/index.js
.我直接在
node_modules/@vuepress/core/lib/node/dev/index.js
添加一行。 This works well, but nasty.这很好用,但很讨厌。
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',
Because Chrome has changed it's security policy, CORS.因为 Chrome 更改了它的安全策略,CORS。
docs/.vuepress/config.js
configureWebpack: (config, isServer) => {
if (!config.devServer) {
config.devServer = {}
}
Object.assign(config.devServer, {
https: true,
})
}
No proper hook没有合适的钩子
No command option for https . https 没有命令选项。
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
Add the following settings to config.js
.将以下设置添加到
config.js
。
//
// docs/.vuepress/config.js
//
module.exports = {
devServer: {
https: true
},
}
Thank you for your guidance in many ways.感谢您多方面的指导。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.