Files
rolegram/vite.config.ts
T
王宏建 258e55b78a feat(project): 初始化 Tauri + Vue + TypeScript 项目
- 添加项目基础配置文件 package.json、tsconfig.json 和 vite.config.ts
- 配置 Git 忽略规则 .gitignore 包含构建产物和开发环境文件
- 设置 VSCode 推荐插件 extensions.json 包含 Volar、Tauri 和 Rust 分析器
- 创建项目主页 index.html 和应用入口 src/main.ts
- 添加 README.md 包含项目介绍和推荐的 IDE 设置
- 安装依赖包包括 @tauri-apps/api、vue、vue-router 等核心库
- 生成 pnpm 锁定文件 pnpm-lock.yaml 确保依赖版本一致性
2026-03-09 16:19:14 +08:00

33 lines
812 B
TypeScript

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/
export default defineConfig(async () => ({
plugins: [vue()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent Vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
// 3. tell Vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
}));