You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, thanks for the great library.
I've set this up in my ./config.ts file as so:
import{parseEnv,z}from"znv";importtype{Environment}from"types";constenvSchema=z.object({VITE_MY_URL: z.string().url(),});/** * Validated environment variables */exportconstenv=parseEnv(import.meta.env,envSchema.shape);/** * This const comes from the extension in `.env.%MODE%` files */exportconstenvironment=import.meta.env.MODEasEnvironment;
An error is thrown when VITE_MY_URL is not supplied during runtime (i.e., in the browser).
However, is there a way to throw an error when running vite build? Currently it passes although I'd expect it to fail.
I thought the solution to run tsx ./config.ts && vite build, but that is not working and throwing this error:
> [email protected] validate /Users/yamcodes/code/my-repo
> tsx src/config.ts
file:///Users/yamcodes/code/my-repo/node_modules/.pnpm/[email protected][email protected]/node_modules/znv/dist/parse-env.js:32
const envValue = env[key];
^
TypeError: Cannot read properties of undefined (reading 'VITE_MY_URL')
at parseEnv (/Users/yamcodes/code/my-repo/node_modules/.pnpm/[email protected][email protected]/node_modules/znv/src/parse-env.ts:116:25)
at <anonymous> (/Users/yborodetsky/code/storemavens/mvns-core/services/mvns-home/src/config.ts:15:20)
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v20.11.1
ELIFECYCLE Command failed with exit code 1.
The text was updated successfully, but these errors were encountered:
Hey, thanks for the great library.
I've set this up in my
./config.ts
file as so:An error is thrown when
VITE_MY_URL
is not supplied during runtime (i.e., in the browser).However, is there a way to throw an error when running
vite build
? Currently it passes although I'd expect it to fail.I thought the solution to run
tsx ./config.ts && vite build
, but that is not working and throwing this error:The text was updated successfully, but these errors were encountered: