vite中获取.env.xxx文件定义的变量
在vite.config.js中获取方式
import { defineConfig, loadEnv } from "vite"; export default ({ mode }) => { server:{ "/api": { target: loadEnv(mode, process.cwd()).VITE_APP_BASE_API, ws: true, changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, "") } } })