Building monorepos - build dependencies?

Say I have monorepo that looks like this:


And both frontend-a and frontend-b have shared-react-components as a dependency like:

"shared-react-components" : "file: ../shared-react-components"

And I want to host both frontend-a and frontend-b on netlify.

Ok, so using the base-directory field, that’s easy enough to do.

When building either frontend, I also need to build the dependencies. Is there a tidy way to do this?

The best I’ve got is making build command:

cd ../shared-react-components && npm i && npm run build && cd ../frontend-a && npm i && npm run build

Hi, @dwjohnston, welcome to our Netlify community site. :slight_smile:

The solution you are using certainly works.

You might also create a build script (for example in package.json) specifically for this, perhaps named netlify-build or something similar, and then call that script using npm run netlify-build instead.

This would add the build command to your site code (so it is tracked in git) and make it a single command you could call at Netlify.

Would that meet the requirements?