Search code examples
cordovaplatform

How to define different file links for different platforms in Cordova


I have an app I'm developing and it's going really well :) I however have run into an issue as it gets bigger and bigger, which is trying to figure out how to write one line of code that will get Cordova to behave the way I want.

Android version has an asset bundle, and therefore the link to my file looks like this:

<video class="video" controls autoplay>
        <source src="file:///android_asset/media/fullversion/littlebunniessleeping.mp4" type="video/mp4" allow fullscreen>
    </video>

And of course the iOS version does not have the bundle, so the link to file is like this:

<video class="video" controls autoplay>
        <source src="../../media/fullversion/littlebunniessleeping.mp4" type="video/mp4" allow fullscreen>
    </video>

So my question is how can I write one line of code so that cordova can automate this process for me? Currently when I go make a new build for the other platform I hack the code up manually, and it's not ideal since there's 40 links like this - will be 160 when I'm done.


Solution

  • The workaround I found is to use the merges folder options for cordova, making separate files for the ios version that replace the ones for Android when making the different build.