Skip to content

Monorepos

While some apps are built from a single repository, Pages also supports apps with more complex setups. A monorepo is a repository that has multiple subdirectories each containing its own application. For monorepos on Cloudflare Workers, refer to Workers Builds monorepos.

Set up

You can create multiple projects using the same repository, in the same way that you would create any other Pages project. You have the option to vary the build command and/or root directory of your project to tell Pages where you would like your build command to run. All project names must be unique even if connected to the same repository.

Builds

When you connect a Git repository to Pages, by default a change to any file in the repository triggers a Pages build.

Monorepo example diagram

Take for example my-monorepo with two associated Pages projects (marketing-app and ecommerce-app) and their listed dependencies. By default, if you change a file in the project directory for marketing-app, then a build for the ecommerce-app project is also triggered, even though ecommerce-app and its dependencies have not changed. To avoid duplicate builds, include and exclude both build watch paths and branches to specify when Pages should skip a build for a given project.

Git integration

Once you have created a separate Pages project for each of the projects within your Git repository, each Git push will issue a new build and deployment for all connected projects unless specified in your build configuration.

GitHub will display separate comments for each project with the updated project and deployment URL if there is a Pull Request associated with the branch.

GitHub check runs and GitLab commit statuses

If you have multiple projects associated with your repository, your GitHub check run ↗︎ or GitLab commit status ↗︎ will appear like the following on your repository:

GitHub check runGitLab commit status

If a build skips for any reason (for example, CI Skip, build watch paths, or branch deployment controls), the check run or commit status does not appear.

Monorepo management tools

While Pages does not provide specialized tooling for dependency management in monorepos, you can bring additional tooling to help manage your repository. For simple subpackage management, use tools like npm ↗︎, pnpm ↗︎, and Yarn ↗︎ workspaces. You can also use tools such as Turborepo ↗︎, Nx ↗︎, or Lerna ↗︎ to manage dependencies and task execution.

Limitations

Was this helpful?