Build configuration cannot be set in targetDependencies
See original GitHub issueCurrent Behavior
Current Behavior: One target can be made dependent on other targets by defining the targetDependencies. example:
"targetDependencies": {
"deploy": [
{
"target": "build-nx-prod",
"projects": "self"
}
]
}
But there is no way to define the build target’s configuration in the dependency. eg:
If I run
npx nx affected --target=deploy -c=production --parallel --max-parallel=3 --stage=pr --skip-nx-cache
in my CI/CD pipeline using github actions.
The build target with default configuration is run and not the defined -c=production configuration.
Expected Behavior
Expected Behavior: When we run the above command from ci.yml file the ci should pick the build configuration and not the default one. We need a way where we can define the configuration in nx so it is picked correctly.
No
Steps to Reproduce
- Create two targets in project.json of an app.
- Call them build and deploy
- add build configuation like
"build": {
"executor": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/administration",
"aot": true,
"index": "apps/administration/src/index.html",
"main": "apps/administration/src/main.ts",
"tsConfig": "apps/administration/tsconfig.app.json",
"polyfills": "apps/administration/src/polyfills.ts",
"assets": [
"apps/administration/src/assets",
"apps/administration/src/favicon.ico",
{
"glob": "**/*",
"input": "libs/web/angular/shared/data-access/application-api/src/lib/assets",
"output": "/assets"
},
{
"glob": "**/*",
"input": "qa-data",
"output": "/assets"
},
{
"input": "libs/configuration/src/lib",
"glob": "frameRedirect.html",
"output": "/"
},
{
"input": "node_modules/msal/dist",
"glob": "msal.min.js",
"output": "/"
},
{
"input": "config",
"glob": "config.json",
"output": "/"
},
{
"glob": "configuration.js",
"input": "libs/logging/src/lib/new-relic",
"output": "/newrelic"
}
],
"styles": [
"node_modules/normalize.css/normalize.css",
"node_modules/bootstrap/dist/css/bootstrap.css",
"apps/administration/src/styles.scss"
],
"scripts": ["node_modules/msal/dist/msal.js"]
},
"configurations": {
"development": {
"baseHref": "/",
"outputPath": "/"
},
"production": {
"baseHref": "/administration/",
"outputHashing": "all",
"sourceMap": true,
"optimization": true,
"outputPath": "dist/administration",
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"fileReplacements": [
{
"replace": "apps/administration/src/environments/environment.ts",
"with": "apps/administration/src/environments/environment.prod.ts"
},
{
"replace": "environments/environment.ts",
"with": "environments/environment.prod.ts"
}
],
"namedChunks": false,
"extractLicenses": true
},
}}
- Add the targetDependencies in nx.json
"targetDependencies": {
"deploy": [
{
"target": "build",
"projects": "self"
}
]
},
- Run the Ci command npx nx affected --target=deploy -c=production --parallel --max-parallel=3 --stage=pr --skip-nx-cache
You will notice the -c=production is not run instead it runs only the default options in the build target.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5
Experiencing a similar issue, I think when we define the targetDependencies, we need another field to specify the configuration. like
@elgurinn No not now. This seems to be an issue with NX. All I did as a workaround is created the target with options that I need to run from my CI.