Ask Your Question
4

How can custom-cli targets be added to the project.json file in Angular using Nx?

asked 2023-02-14 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-05-31 23:00:00 +0000

lalupa gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-02-14 11:00:00 +0000

Seen: 14 times

Last updated: May 31 '22