@idleberg/vite-plugin-devcert 0.1.0 → 0.1.2
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/README.md +5 -5
- package/dist/plugin.d.ts +17 -8
- package/dist/plugin.js +4 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
[](https://github.com/idleberg/vite-plugin-devcert/actions/workflows/node.yml)
|
|
9
9
|
[](https://github.com/idleberg/vite-plugin-devcert/actions/workflows/deno.yml)
|
|
10
10
|
|
|
11
|
-
> !
|
|
12
|
-
> This plugin is based on `@expo/devcert
|
|
11
|
+
> [!IMPORTANT]
|
|
12
|
+
> This plugin is based on [`@expo/devcert`](https://www.npmjs.com/package/@expo/devcert), an actively maintained fork of `devcert`. Read about [how it works](https://github.com/expo/devcert/#how-it-works) and adresses [security concerns](https://github.com/expo/devcert/#security-concerns).
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -44,11 +44,11 @@ export default defineConfig({
|
|
|
44
44
|
|
|
45
45
|
#### `options.skipHostsFile`
|
|
46
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).
|
|
47
|
+
If `certutil` is not installed already (for updating NSS databases; e.g. Firefox), do not attempt to install it. [Read the documention for more](https://github.com/expo/devcert#skiphostsfile).
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
#### `options.skipCertutil`
|
|
50
50
|
|
|
51
|
-
Do not update your systems host file with the domain name of the certificate. [Read more](https://github.com/expo/devcert#skipcertutil).
|
|
51
|
+
Do not update your systems host file with the domain name of the certificate. [Read the documention for more](https://github.com/expo/devcert#skipcertutil).
|
|
52
52
|
|
|
53
53
|
## Related
|
|
54
54
|
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
-
type PluginOptions =
|
|
4
|
-
|
|
3
|
+
type PluginOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* If `certutil` is not installed already (for updating NSS databases; e.g. Firefox), do not attempt to install it.
|
|
6
|
+
* {@see {@link https://github.com/expo/devcert#skiphostsfile}}
|
|
7
|
+
*/
|
|
8
|
+
skipHostsFile: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Do not update your systems host file with the domain name of the certificate.
|
|
11
|
+
* {@see {@link https://github.com/expo/devcert#skipcertutil}}
|
|
12
|
+
*/
|
|
13
|
+
skipCertutil: boolean;
|
|
5
14
|
};
|
|
6
15
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param options -
|
|
9
|
-
* @returns a Vite
|
|
16
|
+
* Generate trusted SSL/TLS certificates for local development.
|
|
17
|
+
* @param options - options passed to `@expo/devcert`
|
|
18
|
+
* @returns a Vite plugin
|
|
10
19
|
*/
|
|
11
|
-
declare function
|
|
20
|
+
declare function DevcertPlugin(options?: PluginOptions): Plugin;
|
|
12
21
|
|
|
13
|
-
export {
|
|
22
|
+
export { DevcertPlugin as default };
|
package/dist/plugin.js
CHANGED
|
@@ -1,34 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 };
|
|
1
|
+
import {certificateFor}from'@expo/devcert';import r from'log-symbols';function p(i){return {name:"@idleberg/vite-plugin-devcert",config:async(e,{command:n})=>{if(n!=="serve")return;let{server:t}=e;if(t?.https?.key&&t?.https?.cert)return console.warn(`${r.warning} Skipping devcert, key and cert already provided.`),e;let o=t?.host&&typeof t.host=="string"?t.host:"localhost";console.info([`
|
|
2
|
+
${r.info} Generating certificate for "${o}".`,"You may be prompted to enter your password to allow the creation of root certificate authority.",`
|
|
3
|
+
Please refer to documentation at https://github.com/expo/devcert#how-it-works for details.
|
|
4
|
+
`].join(" "));let{key:s,cert:a}=await certificateFor(o,i);return {...e,server:{...t,https:{...t?.https,key:s??void 0,cert:a??void 0}}}}}}export{p as default};
|