Skip to content

Releases: Julien-R44/vite-plugin-validate-env

1.0.0

25 Nov 14:42

Choose a tag to compare

Breaking Changes

Before, the plugin didn't really work at 100%, or at least, it wasn't totally type safe. Only strings were stored in import.meta.env. Even when using z.number() or Schema.number(). Same for all other types other than string. It's all fixed now, everything works as expected. We've changed our strategy and now use define from vite rather than process.env.

This is the main reason for this major version change.

Features

  • Added a debug property in the plugin configuration that allows process.env to be logged before the vite-plugin-validate-env processing

Fixes

  • Previously, when .env file was modified and the vite dev server was running, the changes were not taken into account. This is now fixed

New Contributors

Full Changelog: v0.2.5...v1.0.0

v0.2.4

28 Jun 08:20

Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

v0.2.3

22 Jun 18:55

Choose a tag to compare

  • Fixed issue with optional schemas #9
    View changes on GitHub

v0.2.2

21 Jan 12:14

Choose a tag to compare

No significant changes

    View changes on GitHub

v0.2.1

19 Nov 14:55

Choose a tag to compare

   🚀 Features

    View changes on GitHub

v0.2.0

01 Oct 11:41

Choose a tag to compare

Now we are displaying all validations error at once :

image

Thanks to @reslear for suggesting this idea in #5

Changelog

   🚀 Features

    View changes on GitHub

Support custom prefix

17 Sep 12:19

Choose a tag to compare

What's Changed

Full Changelog: v0.1.2...v0.1.3

Extract builtin validator

07 Sep 12:38

Choose a tag to compare

Only refactoring here. The builtin validator was extracted into @poppinss/validator-lite

Full Changelog: v0.1.0...v0.1.2

Fix typing error

06 Sep 15:45

Choose a tag to compare

🩹 Fixes

  • Remove hardcoded vite prefix (607b973)

🏡 Chore

Zod Validation

05 Sep 16:08

Choose a tag to compare

Zod Validation

You can now use Zod as a validation library, in cases where you need a stricter validation or if you just prefer it.

// env.ts
export default defineConfig({
  validator: 'zod',
  schema: {
    VITE_MY_STRING: z.string().min(5, 'This is too short !').startWith('h').endsWith('/'),
    VITE_ENUM: z.enum(['a', 'b', 'c']),
	VITE_AUTH_API_URL: z
      .string()
      .transform((value) => value.endsWith('/') ? value : `${value}/`),
  }
})

Less verbose import.meta.env typing

Just made a little helper for getting the correct IntelliSense on import.meta.env. Can be used as follows:

type ImportMetaEnvAugmented = import('@julr/vite-plugin-validate-env').ImportMetaEnvAugmented<typeof import('../env').default>

interface ImportMetaEnv extends ImportMetaEnvAugmented {}