vite.config.ts 833 B

12345678910111213141516171819202122232425262728
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import path from 'path' // 引入 Node.js 的 path 模块
  4. // https://vite.dev/config/
  5. export default defineConfig({
  6. plugins: [vue()],
  7. resolve: {
  8. alias: {
  9. '@': path.resolve(__dirname, './src') // 配置 @ 指向 src 目录
  10. },
  11. extensions: ['.ts', '.js', '.vue', '.json'] // 添加这一行
  12. },
  13. server: {
  14. host: '0.0.0.0',//允许所有ip访问
  15. port: 8088,//默认端口
  16. proxy:{
  17. '/api':{
  18. // target:'https://dev3.k12100.net/teaching/api/',//测试环境
  19. target:'http://192.168.1.48:47001/api/',//测试环境
  20. // target:'https://www.k12100.com/teaching/api/',//正式环境
  21. changeOrigin:true,
  22. rewrite:path => path.replace(/^\/api/, '')
  23. }
  24. },
  25. }//配置代理
  26. })