question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build configuration cannot be set in targetDependencies

See original GitHub issue

Current 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

  1. Create two targets in project.json of an app.
  2. Call them build and deploy
  3. 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
        },
}}
  1. Add the targetDependencies in nx.json
"targetDependencies": {
    "deploy": [
      {
        "target": "build",
        "projects": "self"
      }
    ]
  },
  1. 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:open
  • Created a year ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
haven2worldcommented, Sep 30, 2022

Experiencing a similar issue, I think when we define the targetDependencies, we need another field to specify the configuration. like

"targetDependencies": {
    "deploy": [
      {
        "target": "build",
        "configuration": "production/test/e2e",
        "projects": "self"
      }
    ]
  },
1reaction
Indronilcommented, May 17, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set Xcode project dependencies with different build ...
Save this answer. Show activity on this post. In Xcode 11, it appears that if no corresponding configuration is found in the project...
Read more >
Deployment target influences build… | Apple Developer Forums
This is the problem that I met, I'm not able to add the dependencies explicitly. The "Find Implicit Dependencies" is enabled, but after...
Read more >
How to use a custom build configuration in a Swift Package?
We use a custom configuration called "Testing" (instead of the default "Debug" or "Release") when conducting unit tests. However, Swift packages ...
Read more >
Learning the Basics - Gradle User Manual
Modules must be specified in the form of group:module . Example 64. Component selection rule with module target. Groovy Kotlin. build.gradle. configurations ......
Read more >
Understand build configurations - Visual Studio (Windows)
If you can't find solution configuration settings on the toolbar and can't access the Configuration Manager, it might be because you're using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found