@arkenv/vite-plugin 0.0.9 → 0.0.11
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 +22 -37
- package/dist/index.cjs +9 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@arkenv/vite-plugin`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Vite](https://vite.dev/) plugin to validate environment variables at build-time with ArkEnv.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -27,29 +27,29 @@ export default defineConfig({
|
|
|
27
27
|
|
|
28
28
|
## Features
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
- ⚡ **Zero runtime overhead**: Validation happens at build time only
|
|
30
|
+
- Build-time validation - app won't start if environment variables are invalid
|
|
31
|
+
- Typesafe environment variables backed by TypeScript
|
|
32
|
+
- Access to ArkType's powerful type system
|
|
34
33
|
|
|
35
34
|
## Usage
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
Simply add the plugin to your Vite config and define your environment variables:
|
|
38
37
|
|
|
39
38
|
```typescript
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
// vite.config.ts
|
|
40
|
+
import arkenv from "@arkenv/vite-plugin";
|
|
41
|
+
import { defineConfig } from "vite";
|
|
42
|
+
|
|
43
|
+
export default defineConfig({
|
|
44
|
+
plugins: [
|
|
45
|
+
arkenv({
|
|
46
|
+
VITE_API_URL: "string",
|
|
47
|
+
VITE_NODE_ENV: "'development' | 'production' | 'test'",
|
|
48
|
+
"VITE_DEBUG?": 'boolean = false',
|
|
49
|
+
"VITE_ALLOWED_ORIGINS?": 'string[] = []'
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
## Environment Variables
|
|
@@ -63,26 +63,11 @@ VITE_DEBUG=true
|
|
|
63
63
|
VITE_ALLOWED_ORIGINS=http://localhost:3000,https://example.com
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
## TypeScript Integration
|
|
67
|
-
|
|
68
|
-
The plugin automatically provides type information for `import.meta.env`:
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
// TypeScript knows the exact types!
|
|
72
|
-
console.log(import.meta.env.VITE_API_URL); // string
|
|
73
|
-
console.log(import.meta.env.VITE_NODE_ENV); // "development" | "production" | "test"
|
|
74
|
-
console.log(import.meta.env.VITE_DEBUG); // boolean
|
|
75
|
-
```
|
|
76
|
-
|
|
77
66
|
## Examples
|
|
78
67
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
## Documentation
|
|
82
|
-
|
|
83
|
-
For detailed documentation and more examples, visit the [ArkEnv documentation site](https://arkenv.js.org/docs).
|
|
68
|
+
* [with-vite-react-ts](https://github.com/yamcodes/arkenv/tree/main/examples/with-vite-react-ts)
|
|
84
69
|
|
|
85
70
|
## Related
|
|
86
71
|
|
|
87
|
-
- [ArkEnv](https://
|
|
88
|
-
- [ArkType](https://arktype.io/) -
|
|
72
|
+
- [ArkEnv](https://arkenv.js.org) - Core library and docs
|
|
73
|
+
- [ArkType](https://arktype.io/) - Underlying validator / type system
|
package/dist/index.cjs
CHANGED
|
@@ -20,14 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
default: () =>
|
|
23
|
+
default: () => arkenv
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
var import_arkenv = require("arkenv");
|
|
27
27
|
var import_vite = require("vite");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
(
|
|
32
|
-
|
|
33
|
-
}
|
|
28
|
+
function arkenv(options) {
|
|
29
|
+
return {
|
|
30
|
+
name: "@arkenv/vite-plugin",
|
|
31
|
+
config(_config, { mode }) {
|
|
32
|
+
(0, import_arkenv.createEnv)(options, (0, import_vite.loadEnv)(mode, process.cwd(), ""));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnvSchema } from 'arkenv';
|
|
2
2
|
import { Plugin } from 'vite';
|
|
3
3
|
|
|
4
|
-
declare const
|
|
4
|
+
declare function arkenv<const T extends Record<string, string | undefined>>(options: EnvSchema<T>): Plugin;
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export { arkenv as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnvSchema } from 'arkenv';
|
|
2
2
|
import { Plugin } from 'vite';
|
|
3
3
|
|
|
4
|
-
declare const
|
|
4
|
+
declare function arkenv<const T extends Record<string, string | undefined>>(options: EnvSchema<T>): Plugin;
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export { arkenv as default };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { createEnv } from "arkenv";
|
|
3
3
|
import { loadEnv } from "vite";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
4
|
+
function arkenv(options) {
|
|
5
|
+
return {
|
|
6
|
+
name: "@arkenv/vite-plugin",
|
|
7
|
+
config(_config, { mode }) {
|
|
8
|
+
createEnv(options, loadEnv(mode, process.cwd(), ""));
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
10
12
|
export {
|
|
11
|
-
|
|
13
|
+
arkenv as default
|
|
12
14
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkenv/vite-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"author": "Yam Borodetsky <yam@yam.codes>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"main": "./dist/index.cjs",
|
|
10
10
|
"module": "./dist/index.js",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"arkenv": "0.
|
|
12
|
+
"arkenv": "0.7.1"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/react": "^19.1.12",
|