2.6.10 https配置
2019-12-01 本文已影响0人
柠檬与断章
2.6.10 https配置
问题一:HTTPS配置?
DevServer 默认使用 HTTP 协议服务,它也能通过 HTTPS 协议服务。 有些情况下你必须使用 HTTPS,例如 HTTP2 和 Service Worker 就必须运行在 HTTPS 之上。 要切换成 HTTPS 服务,最简单的方式是:
devServer:{https:true}
DevServer 会自动的为你生成一份 HTTPS 证书。
如果你想用自己的证书可以这样配置:
devServer:{https:{key:fs.readFileSync('path/to/server.key'),cert:fs.readFileSync('path/to/server.crt'),ca:fs.readFileSync('path/to/ca.pem')}}