-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Support pre- and post- 'lifecycle' scripts in targets #9054
Comments
After reading through some of the other requests for a pre and post build mechanic I don't think that the core team are going to implement one due the addition of I've come across an instance where changing the name of the Changing this target name to anything other than build results in a build errors, which are below.
Hopefully bumping this will get a few more eyes on this feature request. |
Correct, via
Is more direct than
Similarly,
The target name should not be required to be |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Description
I would like to see Nx support pre- and post- steps on project.json / workspace.json targets.
Motivation
When moving to Nx, we removed a lot of npm scripts that called
ng build
and replaced them with direct use ofnx build
. Sometimes, however, you need to always run a post-build step which with npm is achieved with post scripts, e.g.:The only alternative that I'm aware of with Nx is to do this:
This causes a problem: in order to pass the build configuration, one would have to call
nx build app1 --c test
(note the double dash). However, for other apps that don't need additional build steps, this would benx build app2 -c test
(note the single dash).This is especially troublesome in generic CI workflows, as a single command cannot be used to build all apps.
Suggested Implementation
One possible solution could be to utilise the existing run-commands executor for new pre- and post- 'lifecycle' scripts on any target. These could be defined as such:
The
executor
could be implied for terseness, removing the need for that line.Alternate Implementations
Alternatively, instead of nesting the 'lifecycle' scripts in the targets, Nx could mimic the functionality of npm scripts:
Note, the key / name of the target is important, the order within the file is not.
The text was updated successfully, but these errors were encountered: