Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

vite-plugin-mkcert

liuweiGL1.1mMIT1.17.8TypeScript support: included

Provide certificates for vite's https dev service

vite-plugin, certificate, https, mkcert

readme

中文文档

vite-plugin-mkcert

Use mkcert to provide certificate support for vite https development services.

When should I use this plugin

  1. 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.
  2. I have obsessive-compulsive disorder, and I hope that the browser will not show annoying https certificate errors.

Effect

<summary>View</summary>

localhost

127.0.0.1

localhost

Quick start

  1. Installation dependencies
yarn add vite-plugin-mkcert -D
  1. Configure vite
import {defineConfig} from'vite'
import mkcert from'vite-plugin-mkcert'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    https: true
  }, // Not needed for Vite 5+ (simply omit this option)
  plugins: [mkcert()]
})

Parameters

hosts

Custom hosts, default value is localhost + local ip addrs.

force

Whether to force generate.

autoUpgrade

Whether to automatically upgrade mkcert.

source

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.

mkcertPath

If the network is restricted, you can specify a local mkcert file instead of downloading from the network.

savePath

The location to save the files, such as the downloaded mkcert program and the generated CA file, private key and certificate file, etc. Default value is PLUGIN_DATA_DIR

keyFileName

The name of private key file generated by mkcert

certFileName

The name of cert file generated by mkcert

Mobile devices

For the certificates to be trusted on mobile devices, you will have to install the root CA. It's the rootCA.pem file in the folder printed by mkcert -CAROOT.

On iOS, you can either use AirDrop, email the CA to yourself, or serve it from an HTTP server. After opening it, you need to install the profile in Settings > Profile Downloaded and then enable full trust in it.

For Android, you will have to install the CA and then enable user roots in the development build of your app. See this StackOverflow answer.

Display the debugging information of the plug-in

Set the environment variable DEBUG=vite:plugin:mkcert

CHANGELOG

CHANGELOG

Principle

Use mkcert to install the local CA certificate and generate it for server.https Server certificate.

Friendly reminder

  1. Uninstall the CA certificate: mkcert -uninstall

Thanks

changelog

1.17.8 (2025-03-14)

Bug Fixes

  • upgrade axios to fix security issue (935a13a), closes #106

1.17.7 (2025-02-28)

Bug Fixes

  • Remove @octokit/rest to fix security vulnerability (c1b4468), closes #105

1.17.6 (2024-08-15)

Bug Fixes

Performance Improvements

1.17.5 (2024-03-20)

Bug Fixes

  • axios library (1.6.5) has a vulnerability via the follow-redirects dependency (45a7950), closes #86

1.17.4 (2024-02-27)

Bug Fixes

  • the plugin reports mkcert not recognized as an internal or external command when parentheses in the folder name (02278c8), closes #83

1.17.3 (2024-01-18)

Bug Fixes

  • rollback required node version (782ab10)

1.17.2 (2024-01-09)

Bug Fixes

1.17.1 (2023-11-20)

Bug Fixes

  • typescript can't correct resolve .d.ts file (363d66a)

1.17.0 (2023-11-20)

Bug Fixes

  • upgrade dependencies, fix vulnerability (8c2c0b1), closes #76

Features

1.16.0 (2023-06-28)

Features

  • Support more platforms and architectures (0cb9571), closes #68

1.15.0 (2023-05-04)

Features

1.14.1 (2023-04-26)

Bug Fixes

  • 修复node14不支持replaceAll导致报错的问题 (#66) (6936de3)

1.14.0 (2023-03-30)

Features

1.13.4 (2023-03-23)

Bug Fixes

  • typescript 5.0.2 can not resolve typings (d070319), closes #65

1.13.3 (2023-02-27)

Bug Fixes

  • Illegal operation in linux (d299720), closes #63

1.13.2 (2023-02-20)

Bug Fixes

  • mkcert initialization error (b8e6e96), closes #62

1.13.1 (2023-02-16)

Bug Fixes

  • not working if the mkcert in directory with special charaters (e3a5b63), closes #61

1.13.0 (2023-02-04)

Features

Performance Improvements

1.12.0 (2023-01-31)

Features

1.11.0 (2023-01-12)

Features

  • add savePath keyFileName certFileName parameters (b12de07), closes #56

Performance Improvements

  • upgrade all dependencies (fd5a8c0)

1.10.1 (2022-09-28)

Bug Fixes

  • generated code include vite code (e5adc6b), closes #47
  • vite version range incorrect (1486c44)

1.10.0 (2022-09-26)

Bug Fixes

  • Plugin‘s type definition is not generic (1d031d1), closes #44

Features

  • use peerDependence instead of dependence to control vite version (542f15e)

1.9.0 (2022-07-19)

Features

1.8.1 (2022-07-14)

Bug Fixes

  • get warning from esbuild build (7e4d968)

1.8.0 (2022-07-14)

Features

1.7.2 (2022-06-12)

Bug Fixes

  • local path warning only if path isn't found (#32) (ac7f533)

1.7.1 (2022-06-07)

Bug Fixes

  • local hosts not include ips in node18 (b710399)

1.7.0 (2022-06-07)

Features

  • always include local hosts (6bab2ec)

1.6.4 (2022-05-21)

Bug Fixes

1.6.3 (2022-05-21)

Bug Fixes

  • fix npm package not includes built files (da701ee), closes #31

Reverts

  • Revert "fix: fix npm package not includes built files" (a5f04df)

1.6.2 (2022-05-21)

Bug Fixes

  • fix npm package not includes built files (379624b), closes #31

1.6.1 (2022-05-20)

Bug Fixes

Changelog

v1.6.0(2022-02-25)

:tada: Enhancements

  1. feat: https is enabled by default :point_right: ( liuweigl )

  2. feat: allow force to generate certificate :point_right: ( liuweigl )

:beetle: Bug Fixes

  1. fix: fix access denied error caused by JAVA_HOME close #15 :point_right: ( liuweigl )

:rose: Improve code quality

  1. refactor: replace chalk with picocolors :point_right: ( liuweigl )

:rocket: Improve Performance

  1. perf: upgrade dependencies version :point_right: ( liuweigl )

:blush: Other Changes

  1. chore: remove git merge conflict :point_right: ( liuweigl )

  2. chore: update playground vite config :point_right: ( liuweigl )

v1.5.2(2021-10-08)

:beetle: Bug Fixes

  1. fix: fix the error caused by the path containing spaces close #17 :point_right: ( liuweigl )

:blush: Other Changes

  1. chore: fix changelog author shows incorrect when name containing spaces :point_right: ( liuweigl )

  2. chore: upgrade dependencies :point_right: ( liuweigl )

v1.5.1(2021-08-06)

:beetle: Bug Fixes

  1. fix: fix wrong debug log :point_right: ( [Jeremy Cook](<https://github.com/Jeremy Cook>) )

v1.5.0(2021-08-02)

:tada: Enhancements

  1. feat: support read host from server config :point_right: ( liuweigl )

:beetle: Bug Fixes

  1. fix: fix tsc report an type error :point_right: ( liuweigl )

v1.4.2(2021-08-06)

No Change Log

v1.4.1(2021-07-29)

:tada: Enhancements

  1. feat: pretty write config.json file :point_right: ( liuweigl )

:beetle: Bug Fixes

  1. fix(plugin): mkcert binary lost (#13) :point_right: ( iulo )

:memo: Documents Changes

  1. docs: add hosts parameter description :point_right: ( liuweigl )

:rose: Improve code quality

  1. refactor(plugin): make code clean :point_right: ( liuweigl )

v1.4.0(2021-07-22)

:tada: Enhancements

  1. feat(plugin): add certificate cache :point_right: ( liuweigl )

  2. feat(plugin): 支持自定义域名 (#11) :point_right: ( blacksunset )

:beetle: Bug Fixes

  1. fix(script): fix release workflow wrong :point_right: ( liuweigl )

:rose: Improve code quality

  1. refactor(plugin): Adjust the hosts parameter :point_right: ( liuweigl )

  2. refactor(script): 把 version 跟 changelog 操作拆分开来 :point_right: ( liuweigl )

:blush: Other Changes

  1. chore: adjust filename case :point_right: ( liuweigl )

  2. chore: update tsc outdir structure :point_right: ( liuweigl )

  3. chore: remove jest to keep simple :point_right: ( liuweigl )

  4. chore: update github template :point_right: ( liuweigl )

v1.3.2(2021-07-03)

:beetle: Bug Fixes

  1. fix(script): 修复发包之前没有构建资源 :point_right: ( liuweigl )

v1.3.1(2021-07-03)

:blush: Other Changes

  1. chore: rm needless file :point_right: ( liuweigl )

  2. chore: update CHANGELOG :point_right: ( liuweigl )

v1.3.0(2021-07-03)

:beetle: Bug Fixes

  1. fix(script): fix read config.json error :point_right: ( liuweigl )

  2. fix(plugin): fix linux system permission denied resolve #7 :point_right: ( liuweigl )

:blush: Other Changes

  1. chore: remove unused file :point_right: ( liuweigl )

v1.2.1-beta.1(2021-07-03)

:beetle: Bug Fixes

  1. fix(plugin): fix linux system permission denied resolve #7 :point_right: ( liuweigl )

v1.2.0(2021-07-03)

:beetle: Bug Fixes

  1. fix(script): 修复获取最新版本号错误 :point_right: ( liuweigl )

v1.1.2-beta.1(2021-07-03)

No Change Log

v1.1.2-beta.0(2021-07-03)

No Change Log

v1.1.1(2021-07-03)

No Change Log

v1.1.0(2021-07-03)

:tada: Enhancements

  1. feat(script): 添加 npm 发布环节 :point_right: ( liuweigl )

  2. feat(script): add version command :point_right: ( liuweigl )

  3. feat(plugin): plugin only works in serve mode :point_right: ( liuwei )

  4. feat: add logger prefix :point_right: ( liuwei )

:beetle: Bug Fixes

  1. fix(script): 修复 git commit 类型判断错误 :point_right: ( liuweigl )

:memo: Documents Changes

  1. docs: add changelog link :point_right: ( liuwei )

  2. docs: update plugin readme :point_right: ( liuwei )

:rose: Improve code quality

  1. refactor(script): 调整 git tag 时机 :point_right: ( liuweigl )

:hammer_and_wrench: Update Workflow Scripts

  1. build: fix changelog location incorrect :point_right: ( liuweigl )

  2. build: update release script :point_right: ( liuweigl )

  3. build: 添加发布脚本模块 :point_right: ( liuweigl )

:blush: Other Changes

  1. chore: fix script package version incorrect :point_right: ( liuweigl )

  2. chore: 更新 playground 的依赖 :point_right: ( liuweigl )

  3. chore: 使用 pnpm 包管理器 :point_right: ( liuweigl )

  4. chore: conform with the vite plugin conventions :point_right: ( liuwei )