So i was building my application but a major part of it requires environment variables from vite which
I am using laravel echo here:
window.Echo = new Echo({
broadcaster: 'pusher',
key: import.meta.env.VITE_PUSHER_APP_KEY,
cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1',
wsHost: window.location.hostname,
wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
forceTLS: false,
disableStats: true,
enabledTransports: ['ws', 'wss'],
});
But in the compiled file the environment variables are shown as empty/undefined: this is from the compiled file
window.Echo = new qy({
broadcaster: "pusher",
key: {}.VITE_PUSHER_APP_KEY,
cluster: {}.VITE_PUSHER_APP_CLUSTER ?? "mt1",
wsHost: window.location.hostname,
wsPort: {}.VITE_PUSHER_PORT ?? 80,
wssPort: {}.VITE_PUSHER_PORT ?? 443,
forceTLS: !1,
disableStats: !0,
enabledTransports: ["ws", "wss"]
});
for example the key: is coming something like {}.VITE_PUSHER_KEY, this configuration works in development under npm run dev and build both, and is as per the naming convention of the prefix “VITE_” for import.meta variables in the vite docs. I have tried adding the variables as secrets but I still get the undefined variables in the compiled file