vite-plugin-env-compatible

Environment Variables Compatible

Usage no npm install needed!

<script type="module">
  import vitePluginEnvCompatible from 'https://cdn.skypack.dev/vite-plugin-env-compatible';
</script>

README

vite-plugin-env-compatible

inject to process.env like vue-cli or create-react-app

wakatime NPM Publish downloads npm version License: MIT

Motivation

  • vite expose VITE_XXX to import.meta.env.VITE_XXX, but not loaded to process.env like vue-cli or create-react-app
  • this plugin support setting prefix like VUE_APP_ or REACT_APP_ and loaded to process.env
  • just for compatibility

Usage

yarn add vite-plugin-env-compatible
// vite.config.ts
import envCompatible from 'vite-plugin-env-compatible'

// @see https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    // ...other plugins
    envCompatible(/* options */)
  ],
})

Options

Underlying

  • dotenv & dotenv-expand
  • vite

Further