-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isSsrBuild
set to false
when using ssrLoadModule
with vite dev server
#15509
Comments
Start a new pull request in StackBlitz Codeflow. |
When |
I forked the example here: https://stackblitz.com/edit/vitejs-vite-fknvqz?file=vite.config.ts, it does not change anything. But I really dont understand why/how this change would change anything... |
In the vite = await createServer({
server: { middlewareMode: true },
appType: 'custom',
base,
build: {
ssr: true,
// ...
}
}); |
This forces ALL builds as SSR, as shown here: https://stackblitz.com/edit/vitejs-vite-fknvqz?file=vite.config.ts,src%2FApp.tsx You can see in th DOM or in the console that the runtime is |
oh, I may have misunderstood your issue. Today's schedule is a bit busy, so I may need to come back later to review this issue. I hope someone can help you. |
This is expected as the Vite dev server handles client and server code with a single Vite config. In dev and calling One alternative to fixing your issue is to inject a script like I'll close this issue for now as it's working as expected. But feel free to continue the conversation if you have more questions. |
This is not how you also set |
Describe the bug
I have vite.config.ts that needs to know if we are doing an SSR build when using ssrLoadModule.
Currently, it is set to false.
I need to do this because I need to replace
global
withwindow
using define for CSR.I cant switch it around, because otherwise, window is not defined in SSR.
I dont know if this is a bug, or if there is a way to set it to
true
?Reproduction
https://stackblitz.com/edit/vitejs-vite-5gkbop?file=README.md
Steps to reproduce
Just open the stackblliz link. You can see that
isSsrBuild
is set tofalse
.System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: