Search code examples
ionic-frameworkionic-cli

Can you specify the platform when running ionic serve?


I just updated @ionic/cli to v6.3.0 and noticed that running ionic serve displays the app with the iOS version of default component styles. In prior versions, the Android styles were applied. Is there a way to specify which platform preview is served?

Maybe something like ionic serve --platform android? I don't see anything like that in the documentation.

Related, but not what I'm looking for:

  • I realize you can run ionic serve --lab to see side-by-side iOS/Android versions of the app. This method is sometimes useful, but also some drawbacks (mainly that you cannot resize the device to test different screen sizes).
  • Changing IonicModule.forRoot() to IonicModule.forRoot( { mode: 'md' } ) in /src/app/app.module.ts forces the Android platform styles, but this also forces the Android platform styles when you build/compile for iOS.

Solution

  • Well there's no way you can achieve this with ionic.

    You can achieve this with Google Chrome. In google chrome inspector tools (F12), You can click Toggle device toolbar (Ctrl+Shift+M) and then select any device from the menu. You will need to refresh after selecting the device to see the behavior.