Use mkcert to provide certificate support for vite https development services.
- When you want to use
http/2
to solve the concurrency limit of vite http dev server requests, you find that the browser cache is invalid #2725. - I have obsessive-compulsive disorder, and I hope that the browser will not show annoying https certificate errors.
- Installation dependencies
yarn add vite-plugin-mkcert -D
- Configure vite
import {defineConfig} from'vite'
import mkcert from'vite-plugin-mkcert'
// https://vitejs.dev/config/
export default defineConfig({
server: {
https: true
},
plugins: [mkcert()]
})
Whether to force generate.
Whether to automatically upgrade mkcert
.
Specify the download source of mkcert
, domestic users can set it to coding
to download from the coding.net mirror, or provide a custom BaseSource.
If the network is restricted, you can specify a local mkcert
file instead of downloading from the network.
Custom hosts, default value is localhost
+ local ip addrs
.
Set the environment variable DEBUG
=vite:plugin:mkcert
Use mkcert to install the local CA
certificate and generate it for server.https Server certificate.
mkcert
save directory: PLUGIN_DATA_DIR- Uninstall the
CA
certificate:mkcert uninstall