Skip to content

[Bug] Production build with optimization enabled breaks UI styles/scripts (Angular 20 + Ionic 8) #31857

@tomasthesandbox

Description

@tomasthesandbox

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

18

Description

I am encountering a critical issue when building my Ionic 8 / Angular 20 application for production using the default optimization settings.

The build process completes successfully without errors. However, when deploying the application, the UI appears broken (styles are not applied correctly or components are not rendering), even though the browser network tab shows all JS and CSS files loading with 200 OK and the browser console is completely empty (no errors).

Minimal Reproduction

Steps to Reproduce:

  1. Create a new Ionic/Angular project (or use an existing one with the versions below).
  2. Run ionic build --configuration production (which uses @angular-devkit/build-angular with optimization: true).
  3. Deploy to a static host or serve the www folder.
  4. Open the app in the browser.

Current Behavior: The app loads, but styles/scripts seem corrupted or ignored. The UI is broken (missing styles, interactive elements not working). No errors in the console.

Expected Behavior: The app should look and behave exactly like in the development environment (ionic serve).

Workaround: The only way to fix this was to disable optimization in angular.json for the production configuration:

"optimization": false

OR specifically disabling the build optimizer (if applicable to the schema).

Conclusion: It seems like the build optimizer / minifier in Angular CLI 20 is generating silent corruptions when paired with this specific stack, which prevents the browser from applying the code correctly despite successful download.

Exception or Error


Your Environment

Environment:
- OS: Windows (o tu SO actual)
- Node: v20.19.5
- NPM: 10.8.2
- Angular CLI: 20.3.4
- @ionic/angular: ^8.0.0
- @angular-devkit/build-angular: ^20.0.0

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: repro stepsWe cannot reproduce the issue with the information given

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions