Build watch paths
When you connect a git repository to Pages, by default a change to any file in the repository will trigger a Pages build. You can configure Pages to include or exclude specific paths to specify if Pages should skip a build for a given path. This can be especially helpful if you are using a monorepo project structure and want to limit the amount of builds being kicked off.
To configure which paths are included and excluded:
-
Go to the Workers & Pages in the Cloudflare dashboard.
Go to Workers & Pages -
Find your Pages project.
-
Go to Settings > Build > Build watch paths. Pages will default to setting your project's includes paths to everything ([*]) and excludes paths to nothing (
[]).
The configuration fields can be filled in two ways:
- Static filepaths: Enter the precise name of the file you are looking to include or exclude (for example,
docs/README.md). - Wildcard syntax: Use wildcards to match multiple paths. You can specify wildcards at the start or end of your rule.
For each path in a push event, build watch paths will be evaluated as follows:
- Paths satisfying excludes conditions are ignored first
- Any remaining paths are checked against includes conditions
- If any matching path is found, a build is triggered. Otherwise the build is skipped
Pages will bypass the path matching for a push event and default to building the project if:
- A push event contains 0 file changes, in case a user pushes an empty push event to trigger a build
- A push event contains 3000+ file changes or 20+ commits
If you want to trigger a build only when files change within specific directories, such as project-a/ and packages/. Because * matches across path separators, this includes changes in nested subdirectories like project-a/src/index.js or packages/utils/lib/helpers.ts.
- Include paths:
project-a/*, packages/* - Exclude paths: ``
If you want to trigger a build for any changes, but want to exclude changes to a certain directory, such as all changes in a docs/ directory (including nested paths like docs/guides/setup.md).
- Include paths:
* - Exclude paths:
docs/*
If you want to trigger a build for a specific file or specific filetype, for example all .md files anywhere in the repository.
- Include paths:
*.md - Exclude paths: ``
If you want to trigger a build for changes in src/ but want to ignore changes in src/tests/.
- Include paths:
src/* - Exclude paths:
src/tests/*