feat(core): allow loading env vars by target and configuration (#14998)
This commit is contained in:
parent
d7c8e03b5e
commit
24e87e6cc4
@ -9,16 +9,20 @@ the runtime of an app.
|
||||
|
||||
By default, Nx will load any environment variables you place in the following files:
|
||||
|
||||
1. `apps/my-app/.[target-name].env`
|
||||
2. `apps/my-app/.env.[target-name]`
|
||||
3. `apps/my-app/.local.env`
|
||||
4. `apps/my-app/.env.local`
|
||||
5. `apps/my-app/.env`
|
||||
6. `.[target-name].env`
|
||||
7. `.env.[target-name]`
|
||||
8. `.local.env`
|
||||
9. `.env.local`
|
||||
10. `.env`
|
||||
1. `apps/my-app/.env.[target-name].[configuration-name]`
|
||||
2. `apps/my-app/.[target-name].[configuration-name].env`
|
||||
3. `apps/my-app/.env.[target-name]`
|
||||
4. `apps/my-app/.[target-name].env`
|
||||
5. `apps/my-app/.env.local`
|
||||
6. `apps/my-app/.local.env`
|
||||
7. `apps/my-app/.env`
|
||||
8. `.env.[target-name].[configuration-name]`
|
||||
9. `.[target-name].[configuration-name].env`
|
||||
10. `.env.[target-name]`
|
||||
11. `.[target-name].env`
|
||||
12. `.local.env`
|
||||
13. `.env.local`
|
||||
14. `.env`
|
||||
|
||||
{% callout type="warning" title="Order is important" %}
|
||||
Nx will move through the above list, ignoring files it can't find, and loading environment variables
|
||||
|
||||
@ -385,11 +385,27 @@ export class ForkedProcessTaskRunner {
|
||||
...this.getDotenvVariablesForForkedProcess(),
|
||||
...parseEnv(`.${task.target.target}.env`),
|
||||
...parseEnv(`.env.${task.target.target}`),
|
||||
...(task.target.configuration
|
||||
? parseEnv(`.${task.target.target}.${task.target.configuration}.env`)
|
||||
: {}),
|
||||
...(task.target.configuration
|
||||
? parseEnv(`.env.${task.target.target}.${task.target.configuration}`)
|
||||
: {}),
|
||||
...parseEnv(`${task.projectRoot}/.env`),
|
||||
...parseEnv(`${task.projectRoot}/.local.env`),
|
||||
...parseEnv(`${task.projectRoot}/.env.local`),
|
||||
...parseEnv(`${task.projectRoot}/.${task.target.target}.env`),
|
||||
...parseEnv(`${task.projectRoot}/.env.${task.target.target}`),
|
||||
...(task.target.configuration
|
||||
? parseEnv(
|
||||
`${task.projectRoot}/.${task.target.target}.${task.target.configuration}.env`
|
||||
)
|
||||
: {}),
|
||||
...(task.target.configuration
|
||||
? parseEnv(
|
||||
`${task.projectRoot}/.env.${task.target.target}.${task.target.configuration}`
|
||||
)
|
||||
: {}),
|
||||
};
|
||||
} else {
|
||||
return {};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user