Files
coco-app/vite.config.ts

173 lines
4.8 KiB
TypeScript
Raw Normal View History

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";
import { config } from "dotenv";
2025-04-23 18:50:32 +08:00
import packageJson from "./package.json";
config();
2024-10-13 17:41:16 +08:00
const host = process.env.TAURI_DEV_HOST;
// 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({
define: {
2025-04-23 18:50:32 +08:00
"process.env.VERSION": JSON.stringify(packageJson.version),
},
2025-12-18 10:26:13 +08:00
// Keep Tailwind first so its scanner runs early and consistently
plugins: [tailwindcss() as any, react()],
resolve: {
alias: {
2025-04-23 18:50:32 +08:00
"@": 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: 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,
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/**"],
},
proxy: {
2025-12-18 10:26:13 +08:00
"/account": {
target: process.env.COCO_SERVER_URL,
changeOrigin: true,
secure: false,
},
"/chat": {
target: process.env.COCO_SERVER_URL,
changeOrigin: true,
2024-12-10 13:38:31 +08:00
secure: false,
},
"/query": {
target: process.env.COCO_SERVER_URL,
2024-12-10 13:38:31 +08:00
changeOrigin: true,
secure: false,
},
"/connector": {
target: process.env.COCO_SERVER_URL,
changeOrigin: true,
secure: false,
},
"/integration": {
target: process.env.COCO_SERVER_URL,
changeOrigin: true,
secure: false,
},
"/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,
},
"/mcp_server": {
target: process.env.COCO_SERVER_URL,
changeOrigin: true,
secure: false,
},
},
2024-10-13 17:41:16 +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: {
feat: selection settings add & delete (#992) * feat: add selection window page * fix: chat input * feat: add selection page * chore: add * chore: test * feat: add * feat: add store * feat: add selection settings * chore: remove unused code * docs: add release note * docs: add release note * chore: format code * chore: format code * fix: copy error * disable hashbrown default feature * Enable unstable feature allocator_api To make coco-app compile in CI: ``` --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hashbrown-0.15.5/src/raw/mod.rs:3856:12 | 3856 | impl<T, A: Allocator> RawIntoIter<T, A> { | ^^^^^^^^^ | = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information = help: add `#![feature(allocator_api)]` to the crate attributes to enable = note: this compiler was built on 2025-06-25; consider upgrading it if it is out of date ``` I don't know why it does not compile, feature `allocator-api2` is enabled for `hashbrown 0.15.5`, so technically [1] it should not use the allocator APIs from the std. According to [2], enabling the `nightly` feature of `allocator-api2` may cause this issue as well, but it is not enabled in our case either. Anyway, enabling `#![feature(allocator_api)]` should make it work. [1]: https://github.com/rust-lang/hashbrown/blob/b751eef8e99ccf3652046ef4a9e1ec47c1bfb78d/src/raw/alloc.rs#L26-L47 [2]: https://github.com/rust-lang/hashbrown/issues/564 * put it in main.rs * format main.rs * Enable default-features for hashbrown 0.15.5 * format main.rs * enable feature allocator-api2 * feat: add selection set config * fix: selection setting * fix: ci error * fix: ci error * fix: ci error * fix: ci error * merge: merge main * fix: rust code warn * fix: rust code error * fix: rust code error * fix: selection settings * style: selection styles * style: selection styles * feat: selection settings add & delete * feat: selection settings add & delete * feat: selection settings add & delete * style: selection styles * chore: add @tauri-store/zustand plugin * refactor: the selection store using @tauri-store/zustand * fix: data error * fix: data error * chore: remove config * chore: selection * chore: selection * chore: width * chore: ignore selection in the app itself * style: selection styles * style: remove * docs: add notes * chore: add permission check * chore: selection * chore: style & store --------- Co-authored-by: Steve Lau <stevelauc@outlook.com>
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"],
feat: selection settings add & delete (#992) * feat: add selection window page * fix: chat input * feat: add selection page * chore: add * chore: test * feat: add * feat: add store * feat: add selection settings * chore: remove unused code * docs: add release note * docs: add release note * chore: format code * chore: format code * fix: copy error * disable hashbrown default feature * Enable unstable feature allocator_api To make coco-app compile in CI: ``` --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hashbrown-0.15.5/src/raw/mod.rs:3856:12 | 3856 | impl<T, A: Allocator> RawIntoIter<T, A> { | ^^^^^^^^^ | = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information = help: add `#![feature(allocator_api)]` to the crate attributes to enable = note: this compiler was built on 2025-06-25; consider upgrading it if it is out of date ``` I don't know why it does not compile, feature `allocator-api2` is enabled for `hashbrown 0.15.5`, so technically [1] it should not use the allocator APIs from the std. According to [2], enabling the `nightly` feature of `allocator-api2` may cause this issue as well, but it is not enabled in our case either. Anyway, enabling `#![feature(allocator_api)]` should make it work. [1]: https://github.com/rust-lang/hashbrown/blob/b751eef8e99ccf3652046ef4a9e1ec47c1bfb78d/src/raw/alloc.rs#L26-L47 [2]: https://github.com/rust-lang/hashbrown/issues/564 * put it in main.rs * format main.rs * Enable default-features for hashbrown 0.15.5 * format main.rs * enable feature allocator-api2 * feat: add selection set config * fix: selection setting * fix: ci error * fix: ci error * fix: ci error * fix: ci error * merge: merge main * fix: rust code warn * fix: rust code error * fix: rust code error * fix: selection settings * style: selection styles * style: selection styles * feat: selection settings add & delete * feat: selection settings add & delete * feat: selection settings add & delete * style: selection styles * chore: add @tauri-store/zustand plugin * refactor: the selection store using @tauri-store/zustand * fix: data error * fix: data error * chore: remove config * chore: selection * chore: selection * chore: width * chore: ignore selection in the app itself * style: selection styles * style: remove * docs: add notes * chore: add permission check * chore: selection * chore: style & store --------- Co-authored-by: Steve Lau <stevelauc@outlook.com>
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": [
"@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-04-23 18:50:32 +08:00
"tauri-plugins": [
"@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",
2025-04-23 18:50:32 +08:00
"tauri-plugin-fs-pro-api",
"tauri-plugin-macos-permissions-api",
"tauri-plugin-screenshots-api",
"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
});