Hello there :wave:. I have a problem that has bee...
# random
a
Hello there 👋. I have a problem that has been on my mind for a while. In my Next.js app I use a custom backend server. My website uses ISR to stay fast and performant. However, everytime I build my Next.js site, I need to have my backend online. This prevents me from using things like Turborepo, as I cannot run a build command on all the packages my repository has (the website expects the backend package to be running). Has anyone encountered a similar problem? Am I missing something?
t
Could you create a yarn/npm script to handle this? For example, perhaps something like….
Copy code
build: "start server & build site"
or you could even use turbo repo
Copy code
build: "start server & turbo run"
But either way the idea is to have a high level script that runs your backend server prior to running turbo or another build command.
I’ve used this package in the past. https://www.npmjs.com/package/concurrently It allows you to do what I outlined above – wait for 1 command to finish before starting the next, etc.
f
If you need your backend turned on for something like GraphQL codegen there's always the chance of adding your schema as a static output and add it to your vcs, then you wouldn't need to codegen from localhost:4000 every time you want to build something, but instead from a static file
Same applies if you need your server turned on for a swagger codegen pipeline, output the swagger.yml and add it to the vcs