feat: 更新环境变量配置,添加 dotenv 支持并修改 API 代理地址
This commit is contained in:
@@ -2,11 +2,16 @@ import path from "node:path";
|
||||
import legacy from "@vitejs/plugin-legacy";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import jsx from "@vitejs/plugin-vue-jsx";
|
||||
import dotenv from "dotenv";
|
||||
import autoImport from "unplugin-auto-import/vite";
|
||||
import { IonicResolver } from "unplugin-vue-components/resolvers";
|
||||
import components from "unplugin-vue-components/vite";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
const env = dotenv.config({ path: `.env` }).parsed as Record<string, string>;
|
||||
|
||||
console.log("🚀 ~ file: vite.config.ts:7 ~ env:", env);
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@@ -32,7 +37,7 @@ export default defineConfig({
|
||||
host: true,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: "http://192.168.1.36:9527/api",
|
||||
target: env.API_BASE_URL,
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user