Cordova CLI has a really good setup for merging in content that is platform specific under the www
directory.
Basically, under the merges
directory, you can place platform specific directories; mimic the names under platforms
. Under that you can create directories named the same as directories under www
—css
or js
, for example, and the files under those directories will be copied to the platforms
build directories by the cordova prepare
command.
The merges
directory is useful, but limited.
When we had a Cordova app mocked up by a great phonegap consultancy, the end deliverable included large chunks of common css, but some platform specific CSS. Cordova CLI has no issue with this. Another use case would be presenting a common interface for plugins for different platforms that have slightly different APIs–you can write platform specific adapter objects, and place the platform specific javascript into merges
. Here’s an article about another purpose for merges.
merges
are limited, because only directories under www
is merged. If there is anything else you want to modify that is outside of that directory (like, say, AndroidManifest.xml
), well, you are out of luck.
Luckily, hooks come to the rescue again. In the next post, I will discuss how to update platform specific files using Cordova CLI.