vite-plugin-env-sync
v1.0.0
Published
Vite plugin to automatically sync .env keys to .env.example
Maintainers
Readme
vite-plugin-env-sync
A Vite plugin that automatically syncs your .env keys to .env.example — keeping only the key names, not the values.
Installation
# From npm
npm install vite-plugin-env-sync --save-dev
# From GitHub
npm install github:YOUR_USERNAME/vite-plugin-env-sync
# Using bun
bun add vite-plugin-env-sync --dev
# or from GitHub
bun add github:YOUR_USERNAME/vite-plugin-env-syncUsage
Vite
// vite.config.ts
import { defineConfig } from 'vite';
import envSyncPlugin from 'vite-plugin-env-sync';
export default defineConfig({
plugins: [
envSyncPlugin(),
],
});Nuxt
// nuxt.config.ts
import envSyncPlugin from 'vite-plugin-env-sync';
export default defineNuxtConfig({
vite: {
plugins: [
envSyncPlugin(),
],
},
});Options
envSyncPlugin({
// Path to .env file (relative to project root)
envPath: '.env',
// Path to .env.example file (relative to project root)
examplePath: '.env.example',
// Watch for changes during dev (default: true)
watch: true,
})Programmatic API
You can also use the sync function directly:
import { syncEnvExample } from 'vite-plugin-env-sync';
// Syncs .env keys to .env.example
syncEnvExample();
// With options
syncEnvExample({
envPath: '.env.local',
examplePath: '.env.example',
});License
MIT
