vite-plugin-valibot-env
TypeScript icon, indicating that this package has built-in type declarations

0.3.2 • Public • Published

vite-plugin-valibot-env

A Vite plugin to validate environment variables against a Valibot schema.

License Version: npm Version: jsr CI: Node CI: Deno

Installation

npm install -D vite-plugin-valibot-env valibot

Usage

Let's start with very a basic example

import { defineConfig } from 'vite';
import * as v from 'valibot';
import valibot from 'vite-plugin-valibot-env';

const envSchema = v.object({
	VITE_API_ENDPOINT: v.string([v.url()]),
	VITE_ENABLE_LOGGING: v.boolean(),
});

export default defineConfig({
	plugins: [
		valibot(envSchema),
	]
});

API

valibot(schema, options?)

Options

options.ignoreEnvPrefix

Type: Boolean
Default: false

Setting this to true will also validate unprefixed environment variables.

[!TIP] Vite uses a prefix to prevent leaking all environment variables into your code. However, there might be use cases where you want validate unprefixed environment variables as well, e.g. HOST and PORT to configure the Vite server.

License

This work is licensed under The MIT License.

Readme

Keywords

Package Sidebar

Install

npm i vite-plugin-valibot-env

Weekly Downloads

199

Version

0.3.2

License

MIT

Unpacked Size

6.37 kB

Total Files

5

Last publish

Collaborators

  • idleberg