vite

vite.config.js , import.meta.env undefined

import {defineConfig, loadEnv} from 'vite';

export default defineConfig(({ command, mode }) => {
// 根据当前工作目录中的 mode 加载 .env 文件
// 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 VITE_ 前缀。
const env = loadEnv(mode, process.cwd(), '')

return {
// vite 配置
define: {
APP_ENV: env
},
}
})

https://cn.vitejs.dev/config/#async-config

======
vue + vite vconsole
https://blog.csdn.net/m0_53715482/article/details/125590180

posted @ 2022-07-15 16:51  Running00  阅读(164)  评论(0编辑  收藏  举报