- VERSION file at repo root (0.3.0) - vite.config.ts reads VERSION at build time, injects __OIKOS_VERSION__ - App.svelte shows version in sidebar tooltip + subtle text below logo - AGENTS.md §9: every commit to main MUST bump VERSION (patch=bugfix, minor=new features, major=breaking changes)
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import { defineConfig } from 'vite'
|
|
import { readFileSync } from 'fs'
|
|
|
|
const version = readFileSync('../VERSION', 'utf-8').trim()
|
|
|
|
// Injects OIKOS_API_TOKEN into proxied /api requests in dev — the API no
|
|
// longer has a dev-open bypass (plans/2026-07-12-wails-desktop-app.md 0.4),
|
|
// so `OIKOS_API_TOKEN=dev-token npm run dev` needs this to reach it.
|
|
function authProxy(target: string, rewrite?: (path: string) => string) {
|
|
return {
|
|
target,
|
|
...(rewrite ? { rewrite } : {}),
|
|
configure: (proxy: any) => {
|
|
proxy.on('proxyReq', (proxyReq: any) => {
|
|
const token = process.env.OIKOS_API_TOKEN
|
|
if (token) proxyReq.setHeader('Authorization', `Bearer ${token}`)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [tailwindcss(), svelte()],
|
|
base: '/',
|
|
define: {
|
|
__OIKOS_VERSION__: JSON.stringify(`v${version}`),
|
|
},
|
|
resolve: {
|
|
alias: { $lib: '/src/lib' }
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
emptyOutDir: true
|
|
},
|
|
server: {
|
|
proxy: {
|
|
'/api': authProxy('http://localhost:8090'),
|
|
// Production Caddy strips /agent before forwarding to nomos
|
|
// (compose/caddy/Caddyfile.oikos handle_path /agent/*); match that
|
|
// here so dev and prod agree on nomos's actual route paths.
|
|
'/agent': authProxy('http://localhost:8092', (path) => path.replace(/^\/agent/, ''))
|
|
}
|
|
}
|
|
})
|