Conditional compilation of <template> and <script> tags



  • When building the same app for Web & Capacitior targets I’m having errors in such simple code:

    import { Plugins } from '@capacitor/core'
    const { SplashScreen } = Plugins
    

    as this module is not defined in Web but defined in Capacitor. So some problems exists with rendering widgets at mobiles that have software buttons so max-height CSS for them must have different value than Web.

    How people solve this problem ?

    The main idea is to have something like:

    <template>
    #ifdef _capacitor_
    ...
    #endif
    </template>
    
    <script>
    #ifdef _capacitor_
    import 'some capacitor specific'
    #endif
    </script>
    

Log in to reply