Customize how your project is built using vite.config.ts in your project root. Add Vite plugins for frontend builds or define build-time constants.
Basic Configuration
import { defineConfig } from 'vite';
export default defineConfig({
// Configuration options here
});Configuration Options
plugins
Add Vite plugins for frontend builds (src/web/). The CLI passes your vite.config.ts to Vite directly. If the file is missing, the CLI writes a React fallback config for older projects.
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
plugins: [react(), tailwindcss()],
});See the Vite plugin documentation for available plugins.
Vite plugins apply to frontend builds only. Server code is bundled separately with Bun.
define
Replace identifiers with constant values at build time. Values must be JSON-stringified.
import { defineConfig } from 'vite';
export default defineConfig({
define: {
'API_VERSION': JSON.stringify('v2'),
'__DEV__': JSON.stringify(false),
},
});The development asset server sets these keys for Agentuity internals. Avoid redefining them in your Vite config:
- specific
import.meta.env.AGENTUITY_PUBLIC_*keys that Agentuity injects internally process.env.NODE_ENV
Environment Variables
Vite exposes VITE_* variables to frontend code by default. Agentuity's dev server and generated environment types also recognize these public prefixes:
| Prefix | Description |
|---|---|
VITE_* | Standard Vite convention |
AGENTUITY_PUBLIC_* | Agentuity convention |
PUBLIC_* | Short form |
For deployed frontend builds, add envPrefix if you want to expose AGENTUITY_PUBLIC_* or PUBLIC_* variables:
import { defineConfig } from 'vite';
export default defineConfig({
envPrefix: ['VITE_', 'AGENTUITY_PUBLIC_', 'PUBLIC_'],
});// .env.local
AGENTUITY_PUBLIC_API_URL=https://api.example.com
// src/web/App.tsx
const apiUrl = import.meta.env.AGENTUITY_PUBLIC_API_URL;Public environment variables are bundled into frontend code and visible in the browser. Never put secrets or API keys in public variables.
Build Architecture
Agentuity uses a hybrid build system:
| Component | Tool | Output |
|---|---|---|
Frontend (src/web/) | Vite | .agentuity/client/ |
| Server (agents, routes) | Bun | .agentuity/app.js |
This separation allows Vite's optimizations for frontend (HMR, tree-shaking, CSS processing) while using Bun's fast bundling for server code.
For details on how these components interact during development, see Dev Server Architecture.
Full Example
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
// Vite plugins for frontend
plugins: [react(), tailwindcss()],
envPrefix: ['VITE_', 'AGENTUITY_PUBLIC_', 'PUBLIC_'],
// Build-time constants
define: {
'APP_VERSION': JSON.stringify('1.0.0'),
},
});Next Steps
- Tailwind CSS Setup: Add Tailwind styling to your frontend
- Development Server: Run the dev server with your configuration
- Deployment: Deploy with build configuration