Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build time validation for client env #2392

Draft
wants to merge 6 commits into
base: miho-zod-env
Choose a base branch
from

Conversation

infomiho
Copy link
Contributor

@infomiho infomiho commented Nov 29, 2024

This replaces build-time env validation validate-env.mjs script (removed in #2362) with a simple Vite plugin. It removes the dotenv dep requirement and uses the same Zod schema that the runtime validation uses.

This enables us to fail faster in the terminal vs. in the browser console:
Screenshot 2024-11-29 at 11 05 53

@infomiho infomiho mentioned this pull request Nov 29, 2024
5 tasks
name: 'wasp-validate-env',
config: (config) => {
const env = loadEnv(config.mode, process.cwd(), config.envPrefix)
ensureEnvSchema(env, clientEnvSchema)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plugin loads env vars and uses Zod to validate the them using the client env vars schema.

@infomiho infomiho force-pushed the miho-zod-env-client-build-time branch from 432d2f4 to 35bb045 Compare November 29, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant