Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement post tasks on project targets #20799

Open
1 task
rpanadero opened this issue Dec 15, 2023 · 3 comments
Open
1 task

Implement post tasks on project targets #20799

rpanadero opened this issue Dec 15, 2023 · 3 comments
Assignees
Labels
scope: core core nx functionality type: feature

Comments

@rpanadero
Copy link

rpanadero commented Dec 15, 2023

Description

I would like to see Nx support post- tasks on project targets. Other tools like npm do implement this feature.

Motivation

It is very usual to need to run a task after running a target, for example after running build target. Maybe not everyone needs this, but it would be really helpful to have it.

For example, I'm working on an Angular project right now where I need to instrument all generated js files after building for production by running a command. Now, to do it, I would need to add an additional target like "build-full", and rename all references of "build" target to the new "build-full"... Or another approach would be to implement a custom builder for my angular app and give it the ability to run a target after building. Both of them are really tedious, from my point of view. Also, please, consider that other tools like NPM do implement this feature (https://docs.npmjs.com/cli/v10/using-npm/scripts#pre--post-scripts). "DependsOn" works well for pre tasks, but we need something similar for post tasks.

I have seen that this feature request was also requested in the past and discarded, but I would appreciate you check it out again. Le me reference a past requests which was closed by inactivity:

#9054

Suggested Implementation

"build": {
  "executor": "@angular-devkit/build-angular:browser",
  "postTargets": ["postbuild", ...],
  "options": {
     ...
   }
},
"postbuild": {
  "executor": "@nrwl/workspace:run-commands",
  "options": {
      "commands": ["echo 'TEST'"],
   }
}

postTargets syntax would be equal to dependsOn.

Alternate Implementations

"build": {
  "executor": "@angular-devkit/build-angular:browser",
  "options": {
     postTargets: ["myapp:postbuild", ...]
   }
},
"postbuild": {
  "executor": "@nrwl/workspace:run-commands",
  "options": {
      "commands": ["echo 'TEST'"],
   }
}

This approach would allow us to have different post targets by configuration. "PostTargets" option would be like a reserved option for an executor.

@AgentEnder AgentEnder added the scope: core core nx functionality label Dec 21, 2023
@AhsanAyaz
Copy link

Would love to see this being added 👍🏽

@jahusa02
Copy link

I have actually the same usecase. Need to upload sourcemaps to sentry and the esbuild plugin doesnt work with NX/Angular.

@rpanadero
Copy link
Author

This feature request seems to have quite support from the community, could you have a look at it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: core core nx functionality type: feature
Projects
None yet
Development

No branches or pull requests

4 participants