vite.config.ts 776 B

1234567891011121314151617181920212223242526272829303132
  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.1.104:8083', // 目标服务器
  24. target: 'http://192.168.99.49:8083', // 目标服务器
  25. changeOrigin: true, // 需要虚拟主机站点
  26. rewrite: (path) => path.replace(/^\/api/, '/api/') // 重写 API 请求
  27. }
  28. }
  29. }
  30. });