Skip to content

Commit

Permalink
docs(core): add info about defaultConfiguration (#13775)
Browse files Browse the repository at this point in the history
  • Loading branch information
barbados-clemens committed Dec 12, 2022
1 parent e5265d6 commit f0b581d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
30 changes: 29 additions & 1 deletion docs/shared/recipes/use-executor-configurations.md
Expand Up @@ -22,7 +22,7 @@ The `configurations` property provides extra sets of values that will be merged
```

You can select a configuration like this: `nx build mylib --configuration=production`
or `nx run mylib:build:configuration=production`.
or `nx run mylib:build:production`.

The following code snippet shows how the executor options get constructed:

Expand All @@ -36,3 +36,31 @@ require(`@nrwl/jest`).executors['jest']({

The selected configuration adds/overrides the default options, and the provided command line args add/override the
configuration options.

## Default Configuration

When using multiple configurations for a given target, it's helpful to provide a default configuration.
For example, running e2e tests for multiple environments. By default it would make sense to use a `dev` configuration for day to day work, but having the ability to run against an internal staging environment for the QA team.

```json {% fileName="project.json" %}
{
"e2e": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/my-app-e2e/cypress.config.ts"
},
"configurations": {
"dev": {
"devServerTarget": "my-app:serve"
},
"qa": {
"baseUrl": "https://some-internal-url.example.com"
}
},
"defaultConfiguration": "dev"
}
}
```

When running `nx e2e my-app-e2e`, the _dev_ configuration will be used. In this case using the local dev server for `my-app`.
You can always run the other configurations by explicitly providing the configuration i.e. `nx e2e my-app-e2e --configuration=qa` or `nx run my-app-e2e:e2e:qa`
4 changes: 4 additions & 0 deletions packages/nx/schemas/project-schema.json
Expand Up @@ -30,6 +30,10 @@
"type": "string"
}
},
"defaultConfiguration": {
"type": "string",
"description": "The name of a configuration to use as the default if a configuration is not provided"
},
"configurations": {
"type": "object",
"description": "provides extra sets of values that will be merged into the options map",
Expand Down

1 comment on commit f0b581d

@vercel
Copy link

@vercel vercel bot commented on f0b581d Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev

Please sign in to comment.