import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' // 引入 Node.js 的 path 模块 // https://vite.dev/config/ export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': path.resolve(__dirname, './src') // 配置 @ 指向 src 目录 }, extensions: ['.ts', '.js', '.vue', '.json'] // 添加这一行 }, server: { host: '0.0.0.0',//允许所有ip访问 port: 8088,//默认端口 proxy:{ '/api':{ // target:'https://dev3.k12100.net/teaching/api/',//测试环境 target:'http://192.168.1.48:47001/api/',//测试环境 // target:'https://www.k12100.com/teaching/api/',//正式环境 changeOrigin:true, rewrite:path => path.replace(/^\/api/, '') } }, }//配置代理 })