As your workspace grows, running all tasks for all projects on every PR becomes too slow. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nrwl/nx/llms.txt
Use this file to discover all available pages before exploring further.
nx affected command solves this by:
- Determining the minimum set of projects affected by your change
- Running tasks only on those projects
How Nx determines affected projects
Nx combines two sources of information:- Git diff — Nx checks which files changed between the base and head commits
- Project graph — Nx maps those files to projects, then traverses the graph to find all downstream dependents
Run affected tasks
Replacerun-many with affected in your commands:
Control the comparison range with —base and —head
By default, Nx compares against yourmain branch. You can override this:
Use affected in CI
Here is a GitHub Actions example usingnrwl/nx-set-shas to automatically resolve the correct base SHA:
nrwl/nx-set-shas action sets NX_BASE to the last successful CI commit on the base branch, so only work that has not already passed is re-run.
Configure smart dependency update detection
By default, Nx marks all projects as affected when the package manager lock file changes. To opt into more precise behavior that only marks projects depending on the updated packages:projectsAffectedByDependencyUpdates option accepts "auto", "all", or an array of project specifiers.
Ignore files from affected detection
Nx respects two ignore files:.gitignore— any patterns listed here are excluded from affected detection.nxignore— an optional Nx-specific ignore file with the same glob syntax
Not using git?
Pass--files to specify changed files explicitly:
