2024-10-13 17:41:16 +08:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import react from "@vitejs/plugin-react";
|
2025-12-18 10:26:13 +08:00
|
|
|
import tailwindcss from "@tailwindcss/vite";
|
2025-04-23 18:50:32 +08:00
|
|
|
import path from "path";
|
2025-01-06 10:50:44 +08:00
|
|
|
import { config } from "dotenv";
|
2025-04-23 18:50:32 +08:00
|
|
|
import packageJson from "./package.json";
|
2025-01-06 10:50:44 +08:00
|
|
|
|
|
|
|
|
config();
|
2024-10-13 17:41:16 +08:00
|
|
|
|
|
|
|
|
const host = process.env.TAURI_DEV_HOST;
|
2025-01-06 10:50:44 +08:00
|
|
|
// console.log("process.env", process.env)
|
2024-10-13 17:41:16 +08:00
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
2025-12-18 10:26:13 +08:00
|
|
|
export default defineConfig({
|
2025-02-21 18:57:32 +08:00
|
|
|
define: {
|
2025-04-23 18:50:32 +08:00
|
|
|
"process.env.VERSION": JSON.stringify(packageJson.version),
|
2025-02-21 18:57:32 +08:00
|
|
|
},
|
2025-12-18 10:26:13 +08:00
|
|
|
// Keep Tailwind first so its scanner runs early and consistently
|
|
|
|
|
plugins: [tailwindcss() as any, react()],
|
2025-01-02 14:41:54 +08:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
2025-04-23 18:50:32 +08:00
|
|
|
"@": path.resolve(__dirname, "./src"),
|
2025-01-02 14:41:54 +08:00
|
|
|
},
|
|
|
|
|
},
|
2024-10-13 17:41:16 +08:00
|
|
|
// 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: {
|
2025-12-05 09:38:54 +08:00
|
|
|
port: 6060,
|
2024-10-13 17:41:16 +08:00
|
|
|
strictPort: true,
|
|
|
|
|
host: host || false,
|
|
|
|
|
hmr: host
|
|
|
|
|
? {
|
2025-04-23 18:50:32 +08:00
|
|
|
protocol: "ws",
|
|
|
|
|
host,
|
2025-12-05 09:38:54 +08:00
|
|
|
port: 6061,
|
2025-04-23 18:50:32 +08:00
|
|
|
}
|
2024-10-13 17:41:16 +08:00
|
|
|
: undefined,
|
|
|
|
|
watch: {
|
|
|
|
|
// 3. tell vite to ignore watching `src-tauri`
|
|
|
|
|
ignored: ["**/src-tauri/**"],
|
|
|
|
|
},
|
2024-11-09 11:30:36 +08:00
|
|
|
proxy: {
|
2025-12-18 10:26:13 +08:00
|
|
|
"/account": {
|
|
|
|
|
target: process.env.COCO_SERVER_URL,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: false,
|
|
|
|
|
},
|
2024-11-09 11:30:36 +08:00
|
|
|
"/chat": {
|
2025-01-06 10:50:44 +08:00
|
|
|
target: process.env.COCO_SERVER_URL,
|
2024-11-09 11:30:36 +08:00
|
|
|
changeOrigin: true,
|
2024-12-10 13:38:31 +08:00
|
|
|
secure: false,
|
|
|
|
|
},
|
|
|
|
|
"/query": {
|
2025-01-06 10:50:44 +08:00
|
|
|
target: process.env.COCO_SERVER_URL,
|
2024-12-10 13:38:31 +08:00
|
|
|
changeOrigin: true,
|
2024-11-20 10:08:08 +08:00
|
|
|
secure: false,
|
2024-11-09 11:30:36 +08:00
|
|
|
},
|
2025-01-21 19:37:15 +08:00
|
|
|
"/connector": {
|
|
|
|
|
target: process.env.COCO_SERVER_URL,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: false,
|
|
|
|
|
},
|
2025-04-07 11:19:09 +08:00
|
|
|
"/integration": {
|
|
|
|
|
target: process.env.COCO_SERVER_URL,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: false,
|
|
|
|
|
},
|
2025-04-23 18:23:40 +08:00
|
|
|
"/assistant": {
|
|
|
|
|
target: process.env.COCO_SERVER_URL,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: false,
|
|
|
|
|
},
|
|
|
|
|
"/datasource": {
|
|
|
|
|
target: process.env.COCO_SERVER_URL,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: false,
|
|
|
|
|
},
|
2025-04-23 18:50:32 +08:00
|
|
|
"/settings": {
|
|
|
|
|
target: process.env.COCO_SERVER_URL,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: false,
|
|
|
|
|
},
|
2025-07-10 09:48:42 +08:00
|
|
|
"/mcp_server": {
|
|
|
|
|
target: process.env.COCO_SERVER_URL,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: false,
|
|
|
|
|
},
|
2024-11-09 11:30:36 +08:00
|
|
|
},
|
2024-10-13 17:41:16 +08:00
|
|
|
},
|
2025-12-18 15:50:26 +08:00
|
|
|
optimizeDeps: {
|
|
|
|
|
exclude: [
|
|
|
|
|
"@tauri-apps/api",
|
|
|
|
|
"@tauri-apps/api/core",
|
|
|
|
|
"@tauri-apps/api/event",
|
|
|
|
|
"@tauri-apps/api/window",
|
|
|
|
|
"@tauri-apps/api/dpi",
|
|
|
|
|
"@tauri-apps/api/webviewWindow",
|
|
|
|
|
"@tauri-apps/plugin-dialog",
|
|
|
|
|
"@tauri-apps/plugin-process",
|
|
|
|
|
"@tauri-apps/plugin-autostart",
|
|
|
|
|
"@tauri-apps/plugin-clipboard-manager",
|
|
|
|
|
"@tauri-apps/plugin-deep-link",
|
|
|
|
|
"@tauri-apps/plugin-global-shortcut",
|
|
|
|
|
"@tauri-apps/plugin-http",
|
|
|
|
|
"@tauri-apps/plugin-log",
|
|
|
|
|
"@tauri-apps/plugin-opener",
|
|
|
|
|
"@tauri-apps/plugin-os",
|
|
|
|
|
"@tauri-apps/plugin-shell",
|
|
|
|
|
"@tauri-apps/plugin-updater",
|
|
|
|
|
"@tauri-apps/plugin-window",
|
|
|
|
|
"@tauri-store/zustand",
|
|
|
|
|
"tauri-plugin-fs-pro-api",
|
|
|
|
|
"tauri-plugin-macos-permissions-api",
|
|
|
|
|
"tauri-plugin-screenshots-api",
|
|
|
|
|
"tauri-plugin-windows-version-api",
|
|
|
|
|
],
|
|
|
|
|
},
|
2024-12-12 19:41:14 +08:00
|
|
|
build: {
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
|
|
|
|
manualChunks: {
|
2025-12-05 15:32:57 +08:00
|
|
|
react: ["react", "react-dom"],
|
|
|
|
|
router: ["react-router-dom"],
|
|
|
|
|
markdown: [
|
|
|
|
|
"react-markdown",
|
|
|
|
|
"remark-gfm",
|
|
|
|
|
"remark-breaks",
|
|
|
|
|
"remark-math",
|
|
|
|
|
"rehype-highlight",
|
|
|
|
|
"rehype-katex",
|
|
|
|
|
"mdast-util-gfm-autolink-literal",
|
|
|
|
|
],
|
2025-04-23 18:50:32 +08:00
|
|
|
mermaid: ["mermaid"],
|
2025-12-05 15:32:57 +08:00
|
|
|
icons: ["lucide-react", "@infinilabs/custom-icons"],
|
|
|
|
|
utils: ["lodash-es", "dayjs", "uuid", "nanoid", "axios"],
|
2025-04-23 18:50:32 +08:00
|
|
|
"tauri-api": [
|
2025-12-18 15:50:26 +08:00
|
|
|
"@tauri-apps/api",
|
2025-04-23 18:50:32 +08:00
|
|
|
"@tauri-apps/api/core",
|
|
|
|
|
"@tauri-apps/api/event",
|
|
|
|
|
"@tauri-apps/api/window",
|
|
|
|
|
"@tauri-apps/api/dpi",
|
|
|
|
|
"@tauri-apps/api/webviewWindow",
|
2025-03-17 16:24:18 +08:00
|
|
|
],
|
2025-04-23 18:50:32 +08:00
|
|
|
"tauri-plugins": [
|
|
|
|
|
"@tauri-apps/plugin-dialog",
|
|
|
|
|
"@tauri-apps/plugin-process",
|
2025-12-18 15:50:26 +08:00
|
|
|
"@tauri-apps/plugin-autostart",
|
|
|
|
|
"@tauri-apps/plugin-clipboard-manager",
|
|
|
|
|
"@tauri-apps/plugin-deep-link",
|
|
|
|
|
"@tauri-apps/plugin-global-shortcut",
|
|
|
|
|
"@tauri-apps/plugin-http",
|
|
|
|
|
"@tauri-apps/plugin-log",
|
|
|
|
|
"@tauri-apps/plugin-opener",
|
|
|
|
|
"@tauri-apps/plugin-os",
|
|
|
|
|
"@tauri-apps/plugin-shell",
|
|
|
|
|
"@tauri-apps/plugin-updater",
|
|
|
|
|
"@tauri-apps/plugin-window",
|
|
|
|
|
"@tauri-store/zustand",
|
2025-04-23 18:50:32 +08:00
|
|
|
"tauri-plugin-fs-pro-api",
|
|
|
|
|
"tauri-plugin-macos-permissions-api",
|
|
|
|
|
"tauri-plugin-screenshots-api",
|
2025-12-18 15:50:26 +08:00
|
|
|
"tauri-plugin-windows-version-api",
|
2025-04-23 18:50:32 +08:00
|
|
|
],
|
|
|
|
|
},
|
2024-12-12 19:41:14 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
chunkSizeWarningLimit: 600,
|
|
|
|
|
},
|
2025-12-18 10:26:13 +08:00
|
|
|
});
|