No client assets in production
Hi all, I am new to TanStack, and I am using TanStack Start with SolidJS to build a web app. I am using TailwindCSS for styling, and in development, everything works as expected. However, the output from build does not work. I see a "server" and a "client" directory in "dist", so I run the file "dist/server/server.js" with bun. The app still works, but there is no styling. When I check the networks, all the client assets such as css files are not found. Could you show me how to run the build correctly? I think this is not the correct way to run the build, but there is no document about this,
9 Replies
eastern-cyan•20h ago
Hi , server.js exports fetch that you can serve that by Srvx , bun serve and the like
But have you checked this page ?
https://tanstack.com/start/latest/docs/framework/react/hosting
Hosting | TanStack Start React Docs
Hosting is the process of deploying your application to the internet so that users can access it. This is a critical part of any web development project, ensuring your application is available to the...
frail-apricotOP•15h ago
Hi @AMIR , thanks for the reply. I just checked out this page and I am able to make it work with both Srvx, and with the Nitro vite plugin. Thank you so much.
Then, I am also curious, which one is the preferred way to run tanstack app in production? Why do we have 2 different output structure?
ambitious-aqua•15h ago
which one is the preferred way to run tanstack app in productionwhatever suits your needs really you can also embed start into a custom server (e.g. express) it really depends on what you are building
frail-apricotOP•15h ago
Well, I plan to run the webapp (with SSR) in a docker container. Does it make a difference if I use nitro or srvx?
ambitious-aqua•15h ago
nitro moves the relevant node modules into the .output folder, so you end up with a smaller docker image
eastern-cyan•15h ago
As far as I know, there isn’t much difference, but there are a few things you should pay attention to.
For example, if you’re not using a CDN, it’s better to compress assets statically at build time — Nitro can handle that, and there are also some plugins that can help with it.
Nitro uses srvx under the hood. It provides some additional features you might find useful, but note that some features in Nitro aren’t fully functional yet — they may be fixed in Nitro v3.
frail-apricotOP•15h ago
I see, so with the nitro bundle, I don't have to bring the node_modules directory along to the final Docker image.
ambitious-aqua•15h ago
you do, but only the one inside .output
which is most likely smaller than the project one's
try it out and you will see what i mean
frail-apricotOP•15h ago
I will. Thanks for the insight 🙂