vite.config.ts 812 B

1234567891011121314151617181920212223242526272829303132
  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. //获取各种环境下的对应的变量
  7. let env = loadEnv(mode, process.cwd());
  8. return {
  9. plugins: [vue()],
  10. base: "/smartLeader/",
  11. resolve: {
  12. alias: {
  13. "@": fileURLToPath(new URL("./src", import.meta.url)),
  14. },
  15. },
  16. //代理跨域
  17. server: {
  18. proxy: {
  19. [env.VITE_APP_BASE_API]: {
  20. //获取数据的服务器地址设置
  21. target: env.VITE_SERVE,
  22. //需要代理跨域
  23. changeOrigin: true,
  24. //路径重写
  25. rewrite: (path) => path.replace(/^\/smartApi/, ""),
  26. },
  27. },
  28. },
  29. };
  30. });