From a100e4a57ad84e043cd2dba8e7993d2b33628591 Mon Sep 17 00:00:00 2001 From: Brendan Ryan Date: Mon, 16 Mar 2026 11:53:18 -0700 Subject: [PATCH] fix: load env vars into process.env for vocs.config.ts Use Vite's loadEnv() to populate process.env with VITE_* env vars before the vocs() plugin initializes. Without this, VITE_GA_MEASUREMENT_ID is not available when vocs.config.ts is evaluated, causing the Google Analytics gtag to be silently skipped. This matches the pattern used in the mpp site's vite.config.ts. --- vite.config.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 31194ff3..5fb213cb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,12 +2,18 @@ import * as fs from 'node:fs/promises' import * as path from 'node:path' import react from '@vitejs/plugin-react' import { Instance } from 'prool' -import { defineConfig, type Plugin } from 'vite' +import { defineConfig, loadEnv, type Plugin } from 'vite' import { vocs } from 'vocs/vite' // https://vite.dev/config/ -export default defineConfig({ - plugins: [syncTips(), vocs(), react(), tempoNode()], +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), '') + for (const key of Object.keys(env)) { + if (!(key in process.env)) process.env[key] = env[key] + } + return { + plugins: [syncTips(), vocs(), react(), tempoNode()], + } }) function tempoNode(): Plugin {