vite.config.js 713 B

123456789101112131415161718192021222324252627
  1. import {
  2. defineConfig
  3. } from 'vite'
  4. import vue from '@vitejs/plugin-vue'
  5. import path from 'path'
  6. // https://vite.dev/config/
  7. export default defineConfig({
  8. base: './',
  9. plugins: [vue()],
  10. resolve: {
  11. alias: {
  12. '@': path.resolve(__dirname, './src')
  13. }
  14. },
  15. server: {
  16. proxy: {
  17. '/apiV1': { // 配置需要代理的路径 --> 这里的意思是代理http://localhost:80/api/后的所有路由
  18. target: 'https://www.workark.com', // 目标地址 --> 服务器地址
  19. changeOrigin: true, // 允许跨域
  20. ws: true, // 允许websocket代理
  21. // 重写路径 --> 作用与vue配置pathRewrite作用相同
  22. rewrite: (path) => path.replace(/^\/apiV1/, "")
  23. }
  24. },
  25. }
  26. })