2026-10-07 15:10:10 +02:00
|
|
|
import {defineConfig, loadEnv, type Plugin} from 'vite'
|
2026-09-19 14:17:27 +02:00
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
|
2026-10-07 15:10:10 +02:00
|
|
|
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,
|
|
|
|
|
},
|
2026-09-19 14:48:42 +02:00
|
|
|
},
|
|
|
|
|
},
|
2026-10-07 15:10:10 +02:00
|
|
|
}
|
2026-09-19 14:17:27 +02:00
|
|
|
})
|