Ionic Angular build not building with correct styles to android

Creating a new project through the Appflow dashboard will make your project use NgModules instead of Standalone Components.
I think I have found the problem on this thread https://github.com/ionic-team/ionic-framework/issues/28385 where the problem is caused by the build optimizer in production. You can use the command ionic serve --prod and the web result will have the same problems that we have in the android version.

One solution mentioned there is disabling the build optimizer in production in the angular.json file like this:

{
  "projects": {
    "app": {
      "architect": {
        "build": {
          "configurations": {
            "production": {
              "buildOptimizer": false,
              ...
            }
            ...
          }
          ...
        }
        ...
      }
      ...
    }
    ...
  }
  ...
}

Then rebuild your app using ionic build and then build the android version.

There are other solutions mentioned in the thread like this one https://github.com/ionic-team/ionic-framework/issues/28385#issuecomment-1789437096 but I dont understand how it works so I don’t know how to use it.

Also I want to mention that this is a temporal solution and I would like to know how to solve it whithout having to disable the build optimizer.

1 Like