Skip to content

Commit

Permalink
chore(misc): address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Dec 29, 2022
1 parent 815754f commit 63e5abb
Show file tree
Hide file tree
Showing 3 changed files with 299 additions and 100 deletions.
30 changes: 29 additions & 1 deletion docs/shared/reference/nx-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ In this case Nx will use the right `production` input for each project.

Target defaults provide ways to set common options for a particular target in your workspace. When building your project's configuration, we merge it with up to 1 default from this map. For a given target, we look at its name and its executor. We then check target defaults for any of the following combinations:

- `` `${targetName}#${executor}` ``
- `` `${executor}` ``
- `` `${targetName}` ``

Expand Down Expand Up @@ -157,6 +156,35 @@ Another target default you can configure is `outputs`:
}
```

When defining any options or configurations inside of a target default, you may use the `{workspaceRoot}` and `{projectRoot}` tokens. This is useful for defining things like the outputPath or tsconfig for many build targets.

```json {% fileName="nx.json" %}
{
"targetDefaults": {
"@nrwl/js:tsc": {
"options": {
"main": "{projectRoot}/src/index.ts"
},
"configurations": {
"prod": {
"tsconfig": "{projectRoot}/tsconfig.prod.json"
}
},
"inputs": ["prod"],
"outputs": ["{workspaceRoot}/{projectRoot}"]
},
"build": {
"inputs": ["prod"],
"outputs": ["{workspaceRoot}/{projectRoot}"]
}
}
}
```

{% callout type="note" title="Target Default Priority" %}
Note that the inputs and outputs are respecified on the @nrwl/js:tsc default configuration. This is **required**, as when reading target defaults Nx will only ever look at one key. If there is a default configuration based on the executor used, it will be read first. If not, Nx will fall back to looking at the configuration based on target name. For instance, running `nx build project` will read the options from `targetDefaults[@nrwl/js:tsc]` if the target configuration for build uses the @nrwl/js:tsc executor. It **would not** read any of the configuration from the `build` target default configuration unless the executor does not match.
{% /callout %}

### Generators

Default generator options are configured in `nx.json` as well. For instance, the following tells Nx to always
Expand Down
Loading

0 comments on commit 63e5abb

Please sign in to comment.