- Scaffold new applications and libraries with consistent structure
- Augment existing projects with new capabilities (e.g. adding Storybook)
- Enforce organization-wide coding standards automatically
nx generate (or nx g).
Invoke a generator
The syntax isnx g <plugin-name>:<generator-name> [options]:
Preview changes before applying
Use--dry-run to see what files would be created or modified without writing any changes to disk:
List available generators
To see all generators provided by an installed plugin:Interactive mode
When you omit required options, Nx prompts you interactively:Build your own generator
You can write custom generators to automate your organization’s specific workflows. A generator is a function with the following signature:@nx/devkit package provides utilities for reading/writing files, generating names, running tasks, and more.
1
Create the generator
Scaffold a new local generator using the
@nx/plugin generator:2
Implement the generator function
Edit the generated
generator.ts file to implement your logic using @nx/devkit utilities.3
Run your generator
