N
Nuxtβ€’3mo ago
tobi

Nuxt separate API and app for production

Maybe a dumb question, but I didn't find a proper solution in the docs, or here, or on the internet (or I just overlooked it ..) Is it possible to build and deploy a nuxt spa + nuxt nitro server separately? Asking because the client spa shall be bundled with tauri, which then calls the nuxt/nitro api published somewhere else. Another option would be to bundle the server into the tauri app itself, but I didn't get nitro to run inside tauri.. Has anybody done something similiar already and can give some advice? Thanks!
11 Replies
Single
Singleβ€’3mo ago
Yes, generate your site to have a SPA (with or without SSR). Then build your server and deploy it wherever you want. Be sure to make the frontend point to the correct url.
tobi
tobiβ€’3mo ago
I came across this solution as well, thanks! My concern with this solution is, that I need to generate the api, publish it, generate the client and publish the tauri release, as each command uses the same output directory and overwrites the previous build files... this would totally fit my needs if I can specify 2 different output directories, one for each specific build
Single
Singleβ€’3mo ago
I totally get your point. I don't know if there is a solution to build both in one step. Maybe someone else can speak to this.
Sam  K
Sam Kβ€’3mo ago
I am getting around this with a npm workspaces, having the spa as nuxt app and the server with plane nitro. is a bit more complex to setup at first but it made my life easier and more flexible
tobi
tobiβ€’3mo ago
I think I will try to create two build steps - one for spa and one for server, and both of them will move the dist files into a separate folder. This would already satisfy all my needs. I am getting your point, but for the sake of this to create workspaces and two separate packages is a bit of an overkill imho. I think I will go with a simple custom build step script. But thanks for the insights, will keep that in mind!
Single
Singleβ€’3mo ago
Really depends on the size of your project. If you have a 15 minutes buildtime, you will consider πŸ˜‰
tobi
tobiβ€’3mo ago
yeah, that's true - would reconsider using nx for this task instead of workspaces if the app gets bigger as I am using it already in multiple angular enterprise apps successfully. 15 minute build time? how? πŸ˜„ I never reached that stadium; the biggest angular app I am working in (development started 8 years ago, thousands of components, endless domains, subroutes, etc), takes a rough 120 seconds build time (yeah with webpack that was on an all time high of 7 minutes, but in times of esbuild or vite I have never seen such a high build time)
Single
Singleβ€’3mo ago
How? No Idea, but: https://discord.com/channels/473401852243869706/1258775134886432878 120s is not too bad for such a big app πŸ™‚
tobi
tobiβ€’3mo ago
holy cow..this sounds like a nightmare
Sam  K
Sam Kβ€’3mo ago
worked on an ecommerce with NextJS and build and deploy time was around 20 - 25 min. we had to remove the gh workflows as the bills was getting bigger and build locally πŸ˜‚
Single
Singleβ€’3mo ago
ec2 selfhosted runner would have probably been cheaper
Want results from more Discord servers?
Add your server