Getting started
Nx Cloud
Nx Consulting

Running Custom Commands

Compodoc is a great tool for automatically generating documentation for Angular projects. In order to use it, you need to run a simple command in the terminal.

This recipe will show how to run any terminal command within the nx build-chain using Compodoc as an example.


1. Define the terminal command to be run

The command we want to run for each project is:

compodoc -p [path/to/tsconfig.json]
2. Update angular.json

For each project for which you want to enable compodoc, add a target in angular.json:

// ...
"my-app": {
    "architect": {
        "compodoc": {
            "builder": "@nrwl/workspace:run-commands",
                "options": {
                "commands": [
                        "command": "npx compodoc -p apps/my-app/"
        // ...

For more information, see the run-commands api doc.

Note: Replace apps/my-app/ with the appropriate tsconfig.json path for each project.

3. Trigger the builder from the terminal

To run the builder for a single project:

nx run my-app:compodoc

To run the builder for all affected projects:

nx affected --target=compodoc

For more information, see the nx affected.