Files
ads/vite.config.ts
zeekayandHanzo Dev 4c1cde7cad Hanzo Ads runs paid campaigns from a web app
The ad plane at api.hanzo.ai/v1/ad had no screen of its own. This adds one
beside the Go module, built the same way as Hanzo Social: campaigns with their
totals, a campaign to launch, pause, edit or delete, ad accounts connected
through /v1/integration, and spend against budget. It shows only what the API
returns, so there is no targeting, creative or delivery data to draw.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-15 11:16:20 -07:00

44 lines
1.4 KiB
TypeScript

import { hanzo } from '@hanzo/vite'
import react from '@vitejs/plugin-react'
// api.hanzo.ai refuses a credentialed request from a localhost port, so dev and
// preview serve /v1 from their own origin and forward it.
const proxy = { '/v1': { target: 'https://api.hanzo.ai', changeOrigin: true } }
// Pinned: the port is part of the redirect URI registered with hanzo.id.
const PORT = 3310
// Every unknown address must reach the SPA; static hosts serve 404.html for it.
const spaFallback = {
name: 'spa-fallback',
async writeBundle(options: { dir?: string }) {
const { copyFile } = await import('node:fs/promises')
const { join } = await import('node:path')
const dir = options.dir ?? 'dist'
await copyFile(join(dir, 'index.html'), join(dir, '404.html'))
},
}
const config = hanzo(
{
plugins: [react(), spaFallback],
server: { port: PORT, allowedHosts: true, proxy },
preview: { port: PORT, allowedHosts: true, proxy },
},
{
root: import.meta.dirname,
// One copy of the theme context, or components throw "Missing theme."
dedupe: ['@hanzogui/core', '@hanzogui/web', '@hanzogui/portal', '@hanzogui/toast'],
},
)
// The dependency optimizer resolves separately; give it the same web-first extensions.
export default {
...config,
optimizeDeps: {
rollupOptions: {
resolve: { extensions: (config.resolve as { extensions: string[] }).extensions },
},
},
}