Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To add a custom-cli target to the project.json file in Nx, follow these steps:

  1. Open the project.json file in the root directory of your project.
  2. Scroll down to the "architect" section.
  3. Add a new custom-cli target by giving it a unique name and specifying the command to run. For example:
"build-custom": {
   "builder": "@nrwl/workspace:run-commands",
   "options": {
     "commands": [
       {
         "command": "echo 'Custom Build!'"
       }
     ]
   }
}

In this example, a new target named "build-custom" is added, which simply echoes "Custom Build!" when run.

  1. Save the file.

Now you can run the custom-cli target by using the Nx CLI command, e.g. ng run my-project:build-custom.