vite.config.ts server的配置
import { defineConfig } from 'vite' //Install node types before calling below import import {fileURLToPath} from "url"; import path from 'path'; import vue from '@vitejs/plugin-vue' import AutoImport from "unplugin-auto-import/vite"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [ vue(), AutoImport({ //Targets(file extensions) include:[ /\.[tj]sx?$/, //Regex which says t or j followed by sx. tsx jsx ,? next to x says it can happen zero or one time js ,ts /\.vue$/, // $ at the end says it ends with vue ], //globals (libraries) imports:["vue","vue-router","pinia"], //other settings/files/dirs to import dts:true,//Autoimport all the files that ends with d.t //Autoimport inside vue template vueTemplate:true, eslintrc:{enabled:true} }) ], base:"./", resolve:{ alias:{ //Two methods available //Method 1 : using fireURLtoPath(keep adding other paths as needed) "@":fileURLToPath(new URL("./src",import.meta.url)), //Method 2 : using path "@components":path.resolve(__dirname,"src/components"), "@pages":path.resolve(__dirname,"src/pages"), "@layout":path.resolve(__dirname,"src/layout"), "@tests":path.resolve(__dirname,"src/tests"), "@assets":path.resolve(__dirname,"src/assets"), "@api":path.resolve(__dirname,"src/api"), "@stores":path.resolve(__dirname,"src/stores"), "@utils":path.resolve(__dirname,"src/utils"), } }, // 跨域配置 server:{ proxy:{ "/api":{ target:"http://192.168.1.133/api/", changeOrigin:true, rewrite:(path)=>path.replace(/^\/api/,""), } } } })
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现