vite.config.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import path from "path";
  2. const resolve = (dir) => path.resolve(__dirname, dir);
  3. import { defineConfig } from 'vite'
  4. import vue from '@vitejs/plugin-vue'
  5. import {fileURLToPath, URL} from "node:url";
  6. import AutoImport from 'unplugin-auto-import/vite'
  7. import Components from 'unplugin-vue-components/vite'
  8. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  9. // https://vitejs.dev/config/
  10. export default defineConfig({
  11. server:{
  12. cors: true,
  13. https:true,
  14. proxy: {
  15. // 代理所有 /api 的请求,该求情将被代理到 target 中
  16. '/api': {
  17. // 代理请求之后的请求地址(你的真实接口地址)
  18. target: 'https://10.90.11.49:2007/data-business-prod/',
  19. secure: false,
  20. ws: true,
  21. // 跨域
  22. changeOrigin: true,
  23. rewrite: (path) => path.replace(/^\/api/, '')
  24. },
  25. '/addressapi': {
  26. // 代理请求之后的请求地址(你的真实接口地址)
  27. target: 'https://10.90.11.49:2008',
  28. secure: false,
  29. ws: true,
  30. // 跨域
  31. changeOrigin: true,
  32. rewrite: (path) => path.replace(/^\/addressapi/, '')
  33. }
  34. },
  35. },
  36. plugins: [vue(), AutoImport({
  37. resolvers: [ElementPlusResolver()],
  38. }),
  39. Components({
  40. resolvers: [ElementPlusResolver()],
  41. }),],
  42. base:'./',
  43. publicDir: resolve('static'),
  44. resolve: {
  45. alias: {
  46. '@': fileURLToPath(new URL('./src', import.meta.url))
  47. }
  48. }
  49. })