Environment Variables Compatible
npm install vite-plugin-env-compatible> inject to process.env like vue-cli or create-react-app and also define client process.env.XXX for you.
vite expose env to import.meta.env.PREFIX_XXX, but not loaded to process.env like vue-cli or create-react-app.VUE_APP_ or REACT_APP_ and loaded to process.env~~(support by vite@2.5.1).sh
yarn add vite-plugin-env-compatible
``ts
// vite.config.ts
import env from 'vite-plugin-env-compatible'// @see https://vitejs.dev/config/
export default defineConfig({
plugins: [
// ...other plugins
env(/ options /)
],
})
``