1.0.2 • Published 1 year ago

vite-plugin-env-comparison v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

vite-plugin-env-comparison

GitHub Workflow Status npm code style: prettier License: MIT

Plugin is used for synchronization environment variables from sample file to another one.

If you are working with env file which ignored by .gitignore you can create a sample with default values. All new or non-existing variables will be synchronized with your target file.

📦 Install

# Using NPM
npm i -D vite-plugin-env-comparison

# Using Yarn
yarn add -D vite-plugin-env-comparison

# Using pnpm
pnpm add -D vite-plugin-env-comparison

🚀 Usage

Change your Vite config file

import envComparison from 'vite-plugin-env-comparison';
...

export default defineConfig({
  plugin: [
    envComparison({
      source: '.env.local.sample',
      target: '.env.local',
    }),
    ...
  ],
  ...
});

Do not forget to add your .env.local file to .gitgnore ;)

⚙️ Options

export interface EnvComparisonOptions {
  /**
   * Path to source file or array of files
   */
  source: string | string[];

  /**
   * Path to target file
   */
  target: string;

  /**
   * If you need to ignore some environment variables from source file you can pass the environment keys
   */
  ignoreKeys?: string[];

  /**
   * Condition of execution the plugin
   *
   * serve - running only with dev-server
   * build - running with build
   * both - both conditions
   *
   * @defaultValue 'serve'
   */
  executionCondition?: 'serve' | 'build' | 'both';
}