During the Appflow build process, it might be necessary to run custom scripts and it is important to know what will and won't run.
Capacitor hooks are specified in your
package.json to execute scripts around the execution of capacitor commands. Appflow specifically executes
npx cap sync for native builds so the
capacitor:sync:after hooks can be used in the Appflow build process.
Cordova hooks are specified in your
config.xml and when used with the Cordova CLI will execute scripts. Appflow however uses Gym to compile your Application, so Cordova hooks will not run with the exception of
Ionic has a set of hooks which are specified in your
package.json to execute scripts during certain events. These hooks do not run with Appflow.
Npm Pre & Post Scripts
Npm will execute scripts before and after a command is run (documented here). If you create a script called
postbuild in your
package.json these will run before and after the
build step in Appflow.
postbuild script of
package.json will run after your web source code is compiled and not after your native code is compiled.
If you are looking to run scripts during the Appflow build process you can use npm pre & post scripts, the
after_prepare hooks for cordova projects, and the
capacitor:sync:after hooks for Capacitor projects. For additional automation options look at the Appflow Automation feature.