Open samzuercher opened 3 months ago
I found a workaround:
export async function SetLanguage(lang?: ELanguages) {
if (typeof window !== 'undefined') {
// do stuff
const response = await fetch("/en.json");
}
}
Basically just not doing anything when on the server. I think others had similar questions: ~build client-only: https://github.com/antfu/vite-ssg/issues/101
I also tried:
<template>
<ClientOnly>
<main>
<RouterView />
</main>
</ClientOnly>
</template>
But <ClientOnly>
seems to have no effect and was not found..
Why client-only? I like vue to build the frontend. But then i need static files to be hosted on a file server, as the backend might be running in .NET or on Kubernetes and be connected only with API-Calls.
Describe the bug
I try to dynamically language-.json's located in the public-directory. If i can not find any, i try to fetch the english-one like this:
const response = await fetch("/en.json");
Everything works nice with
cross-env DEBUG=vite-ssg:* vite
. When runningvite-ssg build --mode ssg
it builds for client but fails building for server with this:Several Questions:
Reproduction
Please see description
System Info
Used Package Manager
npm
Validations