vite.config.ts 710 B

12345678910111213141516171819202122232425262728293031
  1. import { defineConfig } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import { resolve } from "path";
  4. const pathResolve = (dir: string) => {
  5. return resolve(process.cwd(), ".", dir);
  6. };
  7. // https://vitejs.dev/config/
  8. export default defineConfig({
  9. resolve: {
  10. alias: [
  11. {
  12. find: "@",
  13. replacement: pathResolve("src"),
  14. },
  15. ],
  16. dedupe: ["vue"],
  17. },
  18. plugins: [vue()],
  19. server: {
  20. proxy: {
  21. // 代理配置
  22. '/api': {
  23. target: 'http://192.168.80.252:13002', // 目标服务器
  24. changeOrigin: true, // 需要虚拟主机站点
  25. rewrite: (path) => path.replace(/^\/api/, '/api/') // 重写 API 请求
  26. }
  27. }
  28. }
  29. });