diff --git a/webui/vite.config.js b/webui/vite.config.js index 16e25075..2f0ffe08 100644 --- a/webui/vite.config.js +++ b/webui/vite.config.js @@ -1,9 +1,23 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +import fs from 'node:fs' + +const ANALYTICS_PLACEHOLDER = '' + +function analyticsTags() { + return { + name: 'analytics-tags', + transformIndexHtml(html) { + const tagsPath = new URL('./src/config/analytics.html', import.meta.url) + const tags = fs.existsSync(tagsPath) ? fs.readFileSync(tagsPath, 'utf8').trim() : '' + return html.replace(ANALYTICS_PLACEHOLDER, tags) + }, + } +} // https://vite.dev/config/ export default defineConfig({ - plugins: [react()], + plugins: [react(), analyticsTags()], build: { outDir: '../server/public', emptyOutDir: true,