nx.json Config Builder

Generate an nx.json configuration for Nx-managed monorepos

Builds an nx.json with targetDefaults, named inputs, dependsOn ordering, cacheable operations, outputs, and parallelism settings for fast, computation-cached Nx monorepo workspaces.

What are targetDefaults in nx.json?

targetDefaults set shared configuration for a target name across all projects, so you define build once instead of in every project.json. Each project still overrides or extends these defaults as needed.

Configure an Nx workspace

Nx is a build system for monorepos that adds computation caching, dependency-graph-aware task ordering, and code generation. The root nx.json controls all of it — which targets are cacheable, how tasks order themselves, and which file changes invalidate cached results. This builder produces a correct, modern nx.json.

How it works

targetDefaults holds shared settings keyed by target name (build, test, lint). For each one you set dependsOn for ordering, inputs to control the cache hash, outputs to tell Nx which files to cache, and cache: true to make the target cacheable. The ^build caret means a project’s dependencies build first, mirroring the project graph.

namedInputs defines reusable globs. The default input covers every project file plus shared globals; the production input extends default but excludes test files, so editing a spec invalidates test but not build. These named sets keep cache invalidation precise.

Parallelism is set with the parallel field, or inside tasksRunnerOptions if you opt into the explicit runner form. Recent Nx versions infer cacheable operations directly from the cache flag, so the simpler top-level form is preferred.

Tips and notes

  • Declare outputs accurately — a wrong path means cache hits restore nothing.
  • Use the production named input for build to avoid test files busting the cache.
  • Keep parallel near your CPU core count for best throughput.
  • The explicit tasksRunnerOptions form is only needed for legacy or custom runners.