inject to process.env like vue-cli or create-react-app and also define client
process.env.XXX
for you.
vite
expose env toimport.meta.env.PREFIX_XXX
, but not loaded to process.env like vue-cli or create-react-app.this plugin support setting prefix like(support by [email protected]).VUE_APP_
orREACT_APP_
and loaded to process.env- built-in with vue-cli-plugin-vite just for compatibility.
yarn add vite-plugin-env-compatible
// vite.config.ts
import env from 'vite-plugin-env-compatible'
// @see https://vitejs.dev/config/
export default defineConfig({
plugins: [
// ...other plugins
env(/* options */)
],
})
- dotenv & dotenv-expand
- vite