go-tell/ui/app/vite.config.ts
Daniel Noulet f40485842d
Some checks failed
Build, test, and publish / Build and test (push) Has been cancelled
Build, test, and publish / Build and push Docker image (push) Has been cancelled
CI / test (push) Has been cancelled
fixing style
2026-10-07 15:10:10 +02:00

41 lines
1.1 KiB
TypeScript

import {defineConfig, loadEnv, type Plugin} from 'vite'
import react from '@vitejs/plugin-react'
function themeContract(origin: string): Plugin {
const base = origin.replace(/\/+$/, '')
return {
name: 'go-bananas-contract',
transformIndexHtml(html) {
if (!base) return html
const tags = [
`<link rel="stylesheet" href="${base}/rt/v1/contract.css" data-theme-contract>`,
`<script type="module" src="${base}/rt/v1/components.js"></script>`,
].join('\n ')
return html.replace('</head>', ` ${tags}\n </head>`)
},
}
}
export default defineConfig(({mode}) => {
const env = loadEnv(mode, '.', '')
const themeOrigin = env.VITE_THEME_BASE_URL || ''
return {
plugins: [react(), themeContract(themeOrigin)],
build: {
outDir: '../dist',
emptyOutDir: true,
},
server: {
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
},
'/health': {
target: 'http://localhost:8080',
changeOrigin: true,
},
},
},
}
})