Turborepo Hosting?

I am new to Vercel and would like to ask a question about Vercel’s Turborepo hosting.

My monorepo has packages that contain a React app, some serverless functions, and several packages shared by those (and others).

Vercel handles all aspects of configuring your monorepo, including setting build commands, the Output Directory, the Root Directory, the correct directory for workspaces, and the Ignored Build Step.

This presumably applies to monorepos with just package to be published.

Are there are documents describing the best practice for deploying say serverless functions and a React app, or do I just create a separate project for each?

TIA
Lee

You could do a separate project for each and change to the relevant Root Directory as needed when setting them up. I hope that helps!

The appropriate filter will be automatically inferred based on the configured root directory.

1 Like

For future reference, the root directory needs to be the directory of the sub-package within the monorepo, and the build/install directories need to be specified relative to that.

It is obvious now, of course …

  • Project type: other
  • Root directory: the root of the individual package being deployed - package/x
  • Build build ../../
  • Install ../../
1 Like

Thanks for coming back with the solution, and helping everyone else in the community @leegee!

1 Like

It’s been a long 24-hours, and eventually I discovered that the problem was I had been advised elsewhere to use an .npmrc file with the contents worksapces=true.

That was a bad idea, and broke everything.

By the time I had discovered that, I had already switch to using Turbo, which was a straight forward process, just adding a turbo.json file with a minimal configuration.

Having done that, I turned off all the ‘zero configuration’ options in dashboard, set ‘Framework’ to ‘other,’ and let the root directory blank. That allowed me to use a vercel.json without warnings and confusion:

  "installCommand": "npm install",
  "buildCommand": "npx turbo run build",
  "outputDirectory": "packages/client/build",

This works.

Note to self: the log output running vercel build is actually running the package.json script vercel-build…!

Creating a Vercel Postgres instance has proven to be straight forward: now some fun with hooking up serverless functions! See you in my next confused post…!

Thanks
Lee

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.