2024-10-13 17:41:16 +08:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import react from "@vitejs/plugin-react";
|
2025-01-02 14:41:54 +08:00
|
|
|
import path from 'path';
|
2025-01-06 10:50:44 +08:00
|
|
|
import { config } from "dotenv";
|
2025-02-21 18:57: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/
|
|
|
|
|
export default defineConfig(async () => ({
|
2025-02-21 18:57:32 +08:00
|
|
|
define: {
|
|
|
|
|
'process.env.VERSION': JSON.stringify(packageJson.version),
|
|
|
|
|
},
|
2024-10-13 17:41:16 +08:00
|
|
|
plugins: [react()],
|
2025-01-02 14:41:54 +08:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
|
},
|
|
|
|
|
},
|
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: {
|
|
|
|
|
port: 1420,
|
|
|
|
|
strictPort: true,
|
|
|
|
|
host: host || false,
|
|
|
|
|
hmr: host
|
|
|
|
|
? {
|
2024-12-12 19:41:14 +08:00
|
|
|
protocol: "ws",
|
|
|
|
|
host,
|
|
|
|
|
port: 1421,
|
|
|
|
|
}
|
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: {
|
|
|
|
|
"/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,
|
|
|
|
|
},
|
2024-11-09 11:30:36 +08:00
|
|
|
},
|
2024-10-13 17:41:16 +08:00
|
|
|
},
|
2024-12-12 19:41:14 +08:00
|
|
|
build: {
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
|
|
|
|
manualChunks: {
|
|
|
|
|
vendor: ['react', 'react-dom'],
|
|
|
|
|
katex: ['rehype-katex'],
|
|
|
|
|
highlight: ['rehype-highlight'],
|
|
|
|
|
mermaid: ['mermaid'],
|
2025-03-17 16:24:18 +08:00
|
|
|
'tauri-api': [
|
|
|
|
|
'@tauri-apps/api/core',
|
|
|
|
|
'@tauri-apps/api/event',
|
|
|
|
|
'@tauri-apps/api/window',
|
|
|
|
|
'@tauri-apps/api/dpi',
|
|
|
|
|
'@tauri-apps/api/webviewWindow'
|
|
|
|
|
],
|
|
|
|
|
'tauri-plugins': [
|
|
|
|
|
'@tauri-apps/plugin-dialog',
|
|
|
|
|
'@tauri-apps/plugin-process',
|
|
|
|
|
'tauri-plugin-fs-pro-api',
|
|
|
|
|
'tauri-plugin-macos-permissions-api',
|
|
|
|
|
'tauri-plugin-screenshots-api',
|
|
|
|
|
]
|
2024-12-12 19:41:14 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
chunkSizeWarningLimit: 600,
|
|
|
|
|
},
|
2024-10-13 17:41:16 +08:00
|
|
|
}));
|