vite.config.js 681 B

123456789101112131415161718192021222324252627
  1. import { fileURLToPath, URL } from "node:url";
  2. import { defineConfig, loadEnv } from "vite";
  3. import vue from "@vitejs/plugin-vue";
  4. // https://vitejs.dev/config/
  5. export default defineConfig(({ mode }) => {
  6. const env = loadEnv(mode, process.cwd());
  7. console.log(env);
  8. // const { VUE_APP_BASE_API } = env
  9. return {
  10. plugins: [vue()],
  11. resolve: {
  12. alias: {
  13. "@": fileURLToPath(new URL("./src", import.meta.url)),
  14. },
  15. },
  16. server: {
  17. port: 3000,
  18. proxy: {
  19. "/api/": {
  20. target: env.VITE_APP_SERVER_URL,
  21. changeOrigin: true,
  22. rewrite: (path) => path.replace(/^\/api/, ""),
  23. },
  24. },
  25. },
  26. };
  27. });