@@ -10,11 +10,11 @@ A Vite plugin that validates your environment variables at **build** or **dev ti
1010
1111## ✅ Features
1212
13- * Validate environment variables ** at build time only** , zero runtime overhead
14- * Fully ** type-safe**
15- * Supports [ standard-schema] ( https://github.com/standard-schema/standard-schema ) — works with Zod, Valibot, ArkType, and more
16- * Built-in parsing, validation, and transformation
17- * Custom rules and error messages
13+ - Validate environment variables ** at build time only** , zero runtime overhead
14+ - Fully ** type-safe**
15+ - Supports [ standard-schema] ( https://github.com/standard-schema/standard-schema ) — works with Zod, Valibot, ArkType, and more
16+ - Built-in parsing, validation, and transformation
17+ - Custom rules and error messages
1818
1919---
2020
@@ -43,8 +43,8 @@ export default defineConfig({
4343 ValidateEnv ({
4444 validator: ' builtin' ,
4545 schema: {
46- VITE_MY_VAR: Schema .string ()
47- }
46+ VITE_MY_VAR: Schema .string (),
47+ },
4848 }),
4949 ],
5050})
@@ -64,8 +64,8 @@ export default defineConfig({
6464 ValidateEnv ({
6565 validator: ' standard' , // 👈
6666 schema: {
67- VITE_MY_VAR: z .string ()
68- }
67+ VITE_MY_VAR: z .string (),
68+ },
6969 }),
7070 ],
7171})
@@ -93,9 +93,7 @@ ValidateEnv({
9393 VITE_URL_SUFFIXED_WITH_SLASH : (key , value ) => {
9494 if (! value ) throw new Error (` Missing ${key } ` )
9595
96- return value .endsWith (' /' )
97- ? value
98- : ` ${value }/ `
96+ return value .endsWith (' /' ) ? value : ` ${value }/ `
9997 },
10098})
10199```
@@ -132,10 +130,12 @@ import { defineConfig } from 'vite'
132130import { ValidateEnv } from ' @julr/vite-plugin-validate-env'
133131
134132export default defineConfig ({
135- plugins: [ValidateEnv ({
136- // Optional: you can specify a custom path for the config file
137- configFile: ' config/env'
138- })],
133+ plugins: [
134+ ValidateEnv ({
135+ // Optional: you can specify a custom path for the config file
136+ configFile: ' config/env' ,
137+ }),
138+ ],
139139})
140140```
141141
@@ -144,7 +144,7 @@ export default defineConfig({
144144import { defineConfig , Schema } from ' @julr/vite-plugin-validate-env'
145145
146146export default defineConfig ({
147- validator: " builtin" ,
147+ validator: ' builtin' ,
148148 schema: {
149149 VITE_MY_VAR: Schema .enum ([' foo' , ' bar' ] as const ),
150150 },
@@ -184,22 +184,22 @@ In some cases, you might want to validate environment variables outside of Vite
184184> ` process.env ` only accept string values, so don't be surprised if a ` number ` or ` boolean ` variable comes back as a string when accessing it after validation.
185185
186186``` ts
187- import { loadAndValidateEnv } from ' @julr/vite-plugin-validate-env' ;
187+ import { loadAndValidateEnv } from ' @julr/vite-plugin-validate-env'
188188
189189const env = await loadAndValidateEnv (
190190 {
191191 mode: ' development' , // required
192192 root: import .meta .dirname , // optional
193193 },
194- {
195- // Plugin options. Also optional if you
194+ {
195+ // Plugin options. Also optional if you
196196 // are using a dedicated `env.ts` file
197197 validator: ' builtin' ,
198198 schema: { VITE_MY_VAR: Schema .string () },
199199 },
200- );
200+ )
201201
202- console .log (env .VITE_MY_VAR );
202+ console .log (env .VITE_MY_VAR )
203203console .log (process .env .VITE_MY_VAR )
204204```
205205
0 commit comments