Hooks are pieces of code that Cordova CLI executes at certain points in your Cordova/Ionic application build. Hooks can be used for example to manipulate files in our project, automatically add plugins into your application or as in the example above check for code errors in your files.
The following hook types are supported and execution order is quite self-explanatory according to the name.
pre_package/ <-- Applicable to Windows 8 and Windows Phone only. This hook is deprecated.
Hooks could be defined in project's
<hook> elements, for example:
<hook type="after_build" src="scripts/appAfterBuild.js" />
As a plugin developer you can define hook scripts using
<hook> elements in a
plugin.xml like this:
<hook type="after_build" src="scripts/afterBuild.js" />
before_plugin_uninstall plugin hooks will be fired exclusively for the plugin being installed/uninstalled.
Note: Placing hooks in the
root/hooks directory is considered deprecated in favor of the hook elements in
plugin.xml. If you however use this approach remember to set execute rights to the files in the
Documentation for Cordova Hooks can be found here.