vite.config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import * as path from "path";
  2. const resolve = (dir) => path.resolve(__dirname, dir);
  3. import { fileURLToPath, URL } from 'node:url'
  4. import { defineConfig } from 'vite'
  5. import vue from '@vitejs/plugin-vue'
  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. proxy: {
  14. // 代理所有 /api 的请求,该求情将被代理到 target 中
  15. '/api': {
  16. // 代理请求之后的请求地址(你的真实接口地址)
  17. target: 'https://datamidplat.zjw.sh.cegn.cn:2011/data-business-prod/',
  18. //target: 'http://localhost:9250/',
  19. secure: false,
  20. ws: true,
  21. // 跨域
  22. changeOrigin: true,
  23. rewrite: (path) => path.replace(/^\/api/, '')
  24. }
  25. },
  26. },
  27. https:true,
  28. plugins: [vue(), AutoImport({
  29. resolvers: [ElementPlusResolver()],
  30. }),
  31. Components({
  32. resolvers: [ElementPlusResolver()],
  33. }),],
  34. base:'./',
  35. publicDir: resolve('static'),
  36. resolve: {
  37. alias: {
  38. '@': fileURLToPath(new URL('./src', import.meta.url))
  39. }
  40. },
  41. })