From 42dc187541d28cc26a71545a58607401e91190ef Mon Sep 17 00:00:00 2001 From: bennybrainless <242895261+bennybrainless@users.noreply.github.com> Date: Thu, 20 Nov 2025 23:28:13 -0600 Subject: [PATCH] Ensure web crypto available during Vite build --- discord/vite.config.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/discord/vite.config.ts b/discord/vite.config.ts index eb48216..bc50707 100644 --- a/discord/vite.config.ts +++ b/discord/vite.config.ts @@ -1,7 +1,14 @@ +import { webcrypto } from 'node:crypto' import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import path from "path"; +// Ensure a Web Crypto implementation with getRandomValues exists for Vite's build pipeline +if (!globalThis.crypto?.getRandomValues) { + // @ts-expect-error - assigning Web Crypto to the global crypto reference for Node builds + globalThis.crypto = webcrypto as unknown as Crypto +} + // https://vitejs.dev/config/ export default defineConfig({ base: './',