Files
Frpilot/vite.config.ts
Yuhang Wu b885919b1d feat: 初始化 Tauri + Vue3 项目基础结构
添加了 Tauri 配置、图标资源、Vue3 项目文件、路由、Ant Design Vue 集成、Tailwind CSS 配置等基础内容,完成项目初始化搭建。
2026-10-12 17:24:27 +08:00

63 lines
1.7 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import process from "node:process"
const host = process.env.TAURI_DEV_HOST
import tailwindcss from "@tailwindcss/vite" // 引入插件
import path from "path"
import AutoImport from "unplugin-auto-import/vite"
import Components from "unplugin-vue-components/vite"
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers"
// https://vite.dev/config/
export default defineConfig(() => ({
plugins: [
vue(),
tailwindcss(),
AutoImport({
imports: ["vue", "vue-router", "pinia", "@vueuse/core"],
dts: "src/types/auto-imports.d.ts",
resolvers: [
AntDesignVueResolver({
importStyle: false, // Ant Design Vue 4.x 推荐关闭,使用 CSS-in-JS
}),
],
}),
Components({
resolvers: [
AntDesignVueResolver({
importStyle: false, // Ant Design Vue 4.x 推荐关闭,使用 CSS-in-JS
resolveIcons: true, // 自动导入图标组件(如 <CheckOutlined />)
}),
],
dts: "src/types/components.d.ts",
}),
],
// 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/**"],
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
}))