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

1.0.1 • Public • Published

vite-plugin-watch-env

Apply .env file to process.env and watch file changes in vite.

Install

npm install vite-plugin-watch-env --save-dev
yarn add vite-plugin-watch-env -D
pnpm add vite-plugin-watch-env -D

Usage

// vite.config.ts
import { loadEnv, watchEnv } from 'vite-plugin-watch-env'

export default ({ mode }) => {
  loadEnv(`./.env.${mode}`)
  // here you can access env values from .env file
  console.log(process.env.TEST_ENV_VALUE)

  return defineConfig({
    plugins: [
      watchEnv(),
    ],
    define: {
      'process.env': {
        TEST_ENV_VALUE: process.env.TEST_ENV_VALUE,
      }
    }
  })
}

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i vite-plugin-watch-env

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    7.21 kB

    Total Files

    4

    Last publish

    Collaborators

    • necho