I am working on a monorepo gatsby project that I would like to deploy on Netlify. I am using yarn workspaces to manage the different projects in one repo. I’ve set up a demo repo to show my problem: https://github.com/chrfritsch/netlify-monorepo
In netlify I configured the example folder as base directory. The example project has a dependency on the theme project. The theme project is not published on npm.
It’s not a private npm package, it’s a monorepo. All packages are in the same repository. I want to deploy the example packages, which uses the theme package.
I think the problem is, that the example package does not have a yarn.lock. Because lock files are stored in the root directory in monorepos. And because there is no lock file, netlify tries to build via npm instead of yarn.
In case of monorepos that use yarn workspace I guess using base is not what you want.
Our monorepo feature is built for repos that have their frontend in a subdirectory along with the yarn.lock
E.g. a Golang backend that has docs in /docs or a microservice architecture with the frontend in the same repo under /frontend
For these kinds of sites the base setting is crucial, because otherwise our buildbot can’t detect & cache dependencies.
You have several options:
Use e.g. yarn build as a build command which will run it in all packages, detecting dependencies correctly
Use yarn --cwd packages/package_to_deploy build for running a command from a specific package
Using something like yarn workspace example build in the base directory builds at least the site. But caching doesn’t work. So on every build netlify does a full yarn install. I think it’s because in example/node_modules/.bin there are some symbolic links to /node_modules/
Any update on this? I’m also trying to configure deployment pipeline for a monorepo using Yarn Workspaces where each package (other than one called shared) is a separate static site. But I only have one lockfile at the monorepo root so I’m unable to set things up.