I previously posted about using the
However, there are cases where platform specific Cordova configuration differs from that created by
cordova platforms add [platform]. In this case, if you want to version control the configuration changes (and you should) you need to write a hook to copy over the configuration file from a well known location. I create a top level directory called
config and underneath that have platform specific directories.
However, there are two types of platform specific configuration to consider. The first type aren’t modified by any other processes–application icons and splash screen images are examples of this. In this case, your hook script can live in
.cordova/hooks/after_prepare and be run every time. Therefore, if you switch out a splash screen with a new image, it will show up the very next time you run
The second type of platform specific configuration file is one that is modified by other processes; for example, plugins often modify
AndroidManifest.xml. In this case, if you were to put the copying script into
after_prepare, your plugin changes would be removed unless you reinstalled your plugins every time. The better part of the build lifecycle in which to execute your copy script is
after_platform_add. This means, however, that when you need to change such files, you’ll need to remove and re add the platform (or merge your changes manually).
In the next post, I will discuss adding plugins using Cordova CLI.