website/: fester Umami-Tag fuer opengym.duarte-santos.ch (Landing/About/Docs). frontend/: vite-Plugin injiziert den Tag NUR wenn VITE_UMAMI_SRC und VITE_UMAMI_ID beim Build gesetzt sind — ein normales 'npm run build' und damit jede selbstgehostete Instanz bleibt telemetriefrei. (Die Download-Zeile auf v1.2.7 lag schon uncommitted im Baum und faehrt mit.)
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
const backend = process.env.API_TARGET || 'http://127.0.0.1:3000'
|
|
const media = process.env.MEDIA_TARGET || 'http://127.0.0.1:8888'
|
|
|
|
// Optional web analytics (Umami). Injected only when BOTH vars are set at build time,
|
|
// so a plain `npm run build` — and every self-hosted install — stays telemetry-free.
|
|
// Set for the public instance: VITE_UMAMI_SRC=https://stats.example/script.js VITE_UMAMI_ID=<uuid>
|
|
const umamiSrc = process.env.VITE_UMAMI_SRC
|
|
const umamiId = process.env.VITE_UMAMI_ID
|
|
|
|
const umami = {
|
|
name: 'opengym-umami',
|
|
transformIndexHtml() {
|
|
if (!umamiSrc || !umamiId) return
|
|
return [{
|
|
tag: 'script',
|
|
attrs: { defer: true, src: umamiSrc, 'data-website-id': umamiId },
|
|
injectTo: 'head'
|
|
}]
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [react(), umami],
|
|
base: './',
|
|
server: {
|
|
proxy: {
|
|
'/api': { target: backend, changeOrigin: true },
|
|
'/img': { target: media, changeOrigin: true },
|
|
'/gif': { target: media, changeOrigin: true }
|
|
}
|
|
},
|
|
build: { chunkSizeWarningLimit: 1500 }
|
|
})
|