Build process hook
See original GitHub issueBug Report or Feature Request (mark with an x
)
- [X] feature request
Command (mark with an x
)
- [X] build
Desired functionality
It would be nice to have a hook in the build process, between the index generation and the hash computation, for execute something.
I try to use the Critical lib with my Angular project. First, I build my app, then I use Critical script in order to inline my CSS in the index file : I rewrite my index file. It was messed up with Angular SW, so I submit an issue in Angular’s Github (https://github.com/angular/angular/issues/25267).
@gkalpak explains that the issue result from the stored hash mismatch, because of the rewrite of index file.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:54
- Comments:19 (1 by maintainers)
Top Results From Across the Web
Build Hooks - Builds | OpenShift Container Platform 3.11
Build hooks allow behavior to be injected into the build process. The postCommit field of a BuildConfig object executes commands inside a temporary...
Read more >Customize Build Process with STF_make_rtw_hook File
The build process lets you supply optional custom code in hook methods that are executed at specified points in the code generation and...
Read more >The Guide to Build and Deploy Hooks
Build and Deploy Hooks ... Hook is a term used to indicate a code insertion into some standard operation to provide customization. In...
Read more >Build lifecycle hooks - Expo Documentation
There are five EAS Build lifecycle npm hooks that you can set in your package.json. See the Android build process and iOS build...
Read more >Extending your build process with hooks - CloudCannon
Bash scripts that run at different stages in the build to extend the functionality of your sites. There are three hooks available: Preinstall,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Let me share my use-case. (copied from #16308)
In general,
ng build
is often aliased asnpm run build
. And for production build, oftenng build --prod
is aliased as a different command likenpm run build:prod
. Then mypackage.json
becomes like below;In that case, for adding preprocess script, I have to add it into each scripts like this;
I can use
pre-
hook of npm-scripts, however, a problem is there are two build scripts. It brings a lot of scripts inpackage.json
.This problem can be more serious in a workspace having multiple projects. Each build commands have to take project identifier and often these are separated as different npm-scripts.
Too many npm-scripts are hard to maintain. So I’d like to propose Angular CLI’s command hook feature.
So I’d like to propose CLI command hook as a solution.
CLI command hook is a mechanism to execute a script before/after running CLI’s command. It is not only for
ng build
but all command.With the hook, pre-build code-generation is able to be configured in
angular.json
like below;Once configuring this, it can work with
--prod
or any--configuration
s because each configuration can have its ownhooks
option to override. And any architect commands can be configured as well asbuild
. Each architect author doesn’t have to know about that.This would be helpful.
My situation: I need to compile a TypeScript file and output the JavaScript to the top level in dist. I could do this with a separate build script in package.json, but that gets awkward when running the angular build in watch mode.
What I would like is a lifecycle hook from the
angular.json
that runs a shell command or a JavaScript file. Currently I would need it after the Angular build completes, but I would imagine for other people it would be helpful to have several lifecycle hooks.I’m imagining something like:
It looks like there are other people facing this issue – this answer on this Stack Overflow question suggests starting another parallel process along with
ng build --watch
that watches for changes todist
and runs another command wheneverdist
changes.