Files
desktop/apps/hanzo-desktop/vite.config.ts
zeekay ae31e8cb69 feat: first-class Usage screen tracking AI provider usage
Add /usage route + sidebar nav entry rendering the free-quota block plus
per-provider cards (hanzo/codex/claude) from @hanzo/usage: session and weekly
lane percentages, resets, and spend, using the hanzo-ui kit.

Wire @hanzo/usage (file:../usage/packages/core) via the Tauri fs+http host;
grant capability scope (fs read $HOME/.codex|.claude|.hanzo, http chatgpt.com,
api.anthropic.com, claude.ai, api.hanzo.ai). Dedupe react so the package's
useUsage hook shares the app runtime. Degrades to a connect-providers empty
state outside Tauri.
2026-07-07 15:11:35 -07:00

101 lines
2.9 KiB
TypeScript

import { resolve } from 'path';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import wasm from 'vite-plugin-wasm';
import tsconfigPaths from 'vite-tsconfig-paths';
import tailwindcss from '@tailwindcss/vite';
// https://vitejs.dev/config/
export default defineConfig(() => ({
resolve: {
// @hanzo/usage ships its own react devDep; force a single React instance
// so its useUsage hook shares the app's React runtime.
dedupe: ['react', 'react-dom'],
alias: {
// libsodium-wrappers-sumo ESM entry imports ./libsodium-sumo.mjs which
// lives in the separate libsodium-sumo package
'./libsodium-sumo.mjs': resolve(
__dirname,
'../../node_modules/libsodium-sumo/dist/modules-sumo-esm/libsodium-sumo.mjs',
),
},
},
plugins: [
react(),
tailwindcss(),
tsconfigPaths({ root: '../..' }),
wasm(),
],
esbuild: {
// Important for wasm plugin
supported: {
'top-level-await': true,
bigint: true,
},
},
// 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: 1421,
strictPort: true,
watch: {
// Exclude output.wav from being watched
ignored: ['**/output.wav'],
},
// headers: {
// 'Cross-Origin-Embedder-Policy': 'require-corp',
// 'Cross-Origin-Opener-Policy': 'cross-origin',
// },
},
// 3. to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
// to access the Tauri environment variables set by the CLI with information about the current target
envPrefix: [
'VITE_',
'TAURI_PLATFORM',
'TAURI_ARCH',
'TAURI_FAMILY',
'TAURI_PLATFORM_VERSION',
'TAURI_PLATFORM_TYPE',
'TAURI_DEBUG',
],
build: {
rollupOptions: {
input: {
index: resolve(__dirname, 'index.html'),
hanzo_node_manager: resolve(
__dirname,
'src/windows/hanzo-node-manager/index.html',
),
spotlight: resolve(__dirname, 'src/windows/spotlight/index.html'),
coordinator: resolve(__dirname, 'src/windows/coordinator/index.html'),
hanzo_artifacts: resolve(
__dirname,
'src/windows/hanzo-artifacts/index.html',
),
},
},
},
test: {
watch: false,
setupFiles: './src/test-setup.ts',
globals: true,
cache: { dir: '../../node_modules/.vitest/apps/hanzo-desktop' },
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/libs/hanzo-message-ts',
provider: 'v8',
},
},
worker: {
format: 'es' as const,
},
}));