@idleberg/vite-plugin-devcert 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Jan T. Sott
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @idleberg/vite-plugin-devcert
2
+
3
+ > A Vite plugin to generate trusted SSL/TLS certificates for local development.
4
+
5
+ [![License](https://img.shields.io/github/license/idleberg/vite-plugin-devcert?color=blue&style=for-the-badge)](https://github.com/idleberg/vite-plugin-devcert/blob/main/LICENSE)
6
+ [![Version: npm](https://img.shields.io/npm/v/@idleberg/vite-plugin-devcert?style=for-the-badge)](https://www.npmjs.org/package/@idleberg/vite-plugin-devcert)
7
+ [![Version: jsr](https://img.shields.io/jsr/v/@idleberg/vite-plugin-devcert?style=for-the-badge)](https://jsr.io/@idleberg/vite-plugin-devcert)
8
+ [![CI: Node](https://img.shields.io/github/actions/workflow/status/idleberg/vite-plugin-devcert/node.yml?logo=nodedotjs&logoColor=white&style=for-the-badge)](https://github.com/idleberg/vite-plugin-devcert/actions/workflows/node.yml)
9
+ [![CI: Deno](https://img.shields.io/github/actions/workflow/status/idleberg/vite-plugin-devcert/deno.yml?logo=deno&logoColor=white&style=for-the-badge)](https://github.com/idleberg/vite-plugin-devcert/actions/workflows/deno.yml)
10
+
11
+ > ![NOTE]
12
+ > This plugin is based on `@expo/devcert`, an actively maintained version of `devcert`. Read about [How it works](https://github.com/expo/devcert/tree/master?tab=readme-ov-file#how-it-works) and what the [Security Concerns](https://github.com/expo/devcert/tree/master?tab=readme-ov-file#security-concerns).
13
+
14
+ ## Installation
15
+
16
+ On NodeJS or Bun you can install from npm
17
+
18
+ ```shell
19
+ npm install @idleberg/vite-plugin-devcert
20
+ ```
21
+
22
+ On Deno you can install using JSR
23
+
24
+ ```shell
25
+ deno add jsr:@idleberg/vite-plugin-devcert
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```javascript
31
+ import { defineConfig } from "vite";
32
+ import devCert from "@idleberg/vite-plugin-devcert";
33
+
34
+ export default defineConfig({
35
+ plugins: [devCert()],
36
+ });
37
+ ```
38
+
39
+ ### API
40
+
41
+ `devCert(options?)`
42
+
43
+ ### Options
44
+
45
+ #### `options.skipHostsFile`
46
+
47
+ If `certutil` is not installed already (for updating NSS databases; e.g. Firefox), do not attempt to install it. [Read more](https://github.com/expo/devcert#skiphostsfile).
48
+
49
+ ### `options.skipCertutil``
50
+
51
+ Do not update your systems host file with the domain name of the certificate. [Read more](https://github.com/expo/devcert#skipcertutil).
52
+
53
+ ## Related
54
+
55
+ - [vite-plugin-basic-ssl](https://github.com/vitejs/vite-plugin-basic-ssl)
56
+ - [vite-plugin-mkcert](https://github.com/vite-plugin/vite-plugin-mkcert)
57
+
58
+ ## License
59
+
60
+ This work is licensed under [The MIT License](LICENSE).
@@ -0,0 +1,13 @@
1
+ import { CommonServerOptions, UserConfig, Plugin } from 'vite';
2
+
3
+ type PluginOptions = CommonServerOptions & {
4
+ overrides?: Pick<UserConfig, 'base' | 'cacheDir' | 'clearScreen' | 'customLogger' | 'define' | 'envDir' | 'envPrefix' | 'mode' | 'plugins' | 'publicDir' | 'root'>;
5
+ };
6
+ /**
7
+ * Exports a Vite plugin launches multiple servers.
8
+ * @param options - an array of server options and Vite overrides
9
+ * @returns a Vite plugins
10
+ */
11
+ declare function MultiserverPlugin(options: PluginOptions | PluginOptions[]): Plugin;
12
+
13
+ export { MultiserverPlugin as default };
package/dist/plugin.js ADDED
@@ -0,0 +1,34 @@
1
+ import { certificateFor } from '@expo/devcert';
2
+ import logSymbols from 'log-symbols';
3
+
4
+ // src/plugin.ts
5
+ function DevcertPlugin(options) {
6
+ return {
7
+ name: "@idleberg/vite-plugin-devcert",
8
+ config: async (userConfig, { command }) => {
9
+ if (command !== "serve") {
10
+ return;
11
+ }
12
+ const { server } = userConfig;
13
+ if (server?.https?.key && server?.https?.cert) {
14
+ console.warn(`${logSymbols.warning} Skipping devcert, key and cert already provided.`);
15
+ return userConfig;
16
+ }
17
+ const domain = server?.host && typeof server.host === "string" ? server.host : "localhost";
18
+ const { key, cert } = await certificateFor(domain, options);
19
+ return {
20
+ ...userConfig,
21
+ server: {
22
+ ...server,
23
+ https: {
24
+ ...server?.https,
25
+ key: key ?? void 0,
26
+ cert: cert ?? void 0
27
+ }
28
+ }
29
+ };
30
+ }
31
+ };
32
+ }
33
+
34
+ export { DevcertPlugin as default };
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@idleberg/vite-plugin-devcert",
3
+ "version": "0.1.0",
4
+ "description": "A Vite plugin to generate trusted SSL/TLS certificates for local development",
5
+ "license": "MIT",
6
+ "author": "Jan T. Sott",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/idleberg/vite-plugin-devcert"
10
+ },
11
+ "keywords": [
12
+ "vite-plugin",
13
+ "vite-server",
14
+ "server",
15
+ "http-server",
16
+ "certificate",
17
+ "ssl",
18
+ "tls"
19
+ ],
20
+ "type": "module",
21
+ "exports": "./dist/plugin.js",
22
+ "types": "./dist/plugin.d.ts",
23
+ "engines": {
24
+ "node": "^18.0.0 || ^20.0.0 || >=22.0.0"
25
+ },
26
+ "files": [
27
+ "dist/",
28
+ "LICENSE",
29
+ "README.md"
30
+ ],
31
+ "dependencies": {
32
+ "@expo/devcert": "^1.2.0",
33
+ "log-symbols": "^7.0.1"
34
+ },
35
+ "devDependencies": {
36
+ "@biomejs/biome": "^1.9.4",
37
+ "@commitlint/cli": "^19.8.1",
38
+ "@commitlint/config-conventional": "^19.8.1",
39
+ "@total-typescript/tsconfig": "^1.0.4",
40
+ "@types/node": "^22.15.21",
41
+ "lefthook": "^1.11.13",
42
+ "np": "^10.2.0",
43
+ "tsup": "^8.5.0",
44
+ "typescript": "^5.8.3",
45
+ "vite": "^6.3.5"
46
+ },
47
+ "peerDependencies": {
48
+ "vite": ">=1.0.0 <7.0.0"
49
+ },
50
+ "scripts": {
51
+ "build": "tsup",
52
+ "dev": "tsup --watch",
53
+ "lint": "biome check --no-errors-on-unmatched --vcs-enabled=true --vcs-use-ignore-file=true",
54
+ "publish:jsr": "deno publish",
55
+ "publish:npm": "np --any-branch",
56
+ "test": "echo \"No tests specified\" && exit 0"
57
+ }
58
+ }