App Builder application tooling lifecycle event hooks
Hooks can be defined to run before, after, or in place of many of the app plugin commands in the app.config.yaml or ext.config.yaml file of your app.
Command Support
aio app run
supports:
Copied to your clipboardhooks:pre-app-run: echo pre-app-runpost-app-run: echo post-app-runpre-app-build: echo pre-app-buildpost-app-build: echo post-app-buildpre-app-deploy: echo pre-app-deploypost-app-deploy: echo post-app-deploybuild-actions: echo build-actionsdeploy-actions: echo deploy-actionsbuild-static: echo build-staticserve-static: echo serve-staticpre-app-undeploy: echo pre-app-undeploypost-app-undeploy: echo post-app-undeployundeploy-actions: echo undeploy-actionsundeploy-static: echo undeploy-static
aio app build
supports:
Copied to your clipboardhooks:pre-app-build: echo pre-app-buildpost-app-build: echo post-app-buildbuild-actions: echo build-actionsbuild-static: echo build-static
aio app deploy
supports:
Copied to your clipboardhooks:pre-app-build: echo pre-app-buildpost-app-build: echo post-app-buildpre-app-deploy: echo pre-app-deploypost-app-deploy: echo post-app-deploybuild-actions: echo build-actionsbuild-static: echo build-staticdeploy-actions: echo deploy-actionsdeploy-static: echo deploy-static
aio app undeploy
supports:
Copied to your clipboardhooks:pre-app-undeploy: echo pre-app-undeploypost-app-undeploy: echo post-app-undeployundeploy-actions: echo undeploy-actionsundeploy-static: echo undeploy-static
aio app test
supports:
Copied to your clipboardhooks:test: echo this is your custom test runner
aio app pack
supports:
Copied to your clipboardhooks:pre-pack: echo this is before packagingpost-pack: echo this is after packaging
Use cases
aio app run
hooks:
- manage additional local development tooling that is not managed by the out-of-the-box flow
aio app build
build-static and build-actions hooks:
- build actions to include static files with the action zipfile (for templates like in server-side rendering)
- build the web assets with a different bundler and configuration, for example webpack
aio app deploy
deploy-static and deploy-actions hooks:
- support additional deployment steps (e.g. deploy to multiple servers or locations)
aio app undeploy
undeploy-static and undeploy-actions hooks:
- support additional un-deployment steps (e.g. un-deploy from multiple servers or locations)
aio app test
test hook:
- support a custom test runner for your app or extension
Using JavaScript files
You can specify a JavaScript file that contains your hook code. This file must export a function.
app.config.yaml
Copied to your clipboardhooks:post-app-deploy: ./hooks/post-app-deploy.js
./hooks/post-app-deploy.js
Copied to your clipboardmodule.exports = () => {console.log("Post app deploy hook")}
Legacy App (no extensions)
In the root of your app, you will have to add a hooks
key in the app.config.yaml
file, under the application
key. Example:
Copied to your clipboardapplication:hooks:pre-app-run: echo pre-app-run
If you add extensions to a standalone app via aio app add extension
, note that your app.config.yaml
hooks will always run first, then your extension hooks in each ext.config.yaml
will be run.
App with Extensions
In your app extension folder (typically at src/EXTENSION_NAME
), find the ext.config.yaml
file, and add in a hooks
key. Example:
Copied to your clipboardhooks:pre-app-run: echo pre-app-run
Hooks flow
The following diagram illustrates how your custom hooks will be executed within the application via the various commands: