[SOLVED] Build APP --prod --release error


When i try to run command to release the final version of my app

When using the command

 sudo ionic build ios --release --prod

to generate the final version of application, I get the message…

ionic-app-scripts 1.1.0 
build prod started ... 
clean started ... 
clean finished in 28 ms 
copy started ... 
ngc started ... 
**Failed to parse and update /Users/joe/apps/my-app/sources/src/app/main.ts content for AoT **
**            compilation. For now, the default fallback content will be used instead. Please consider updating **
**            /Users/joe/apps/my-app/sources/src/app/main.ts with the content from the following link: **
**            https://github.com/driftyco/ionic2-app-base/tree/master/src/app/main.ts** 

the content of main.ts is

    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
    import { AppModule } from './app.module';
    import { KeycloakService } from "./keycloak.service"; // see example from  https://github.com/keycloak/keycloak/tree/master/examples/demo-template/angular2-product-app

      .then(() => {
        const platform = platformBrowserDynamic();
      .catch(() => window.location.reload());

This only happens when I run the command

ionic build ios --prod --release

Using only the command

ionic build ios --prod 

the message don’t appear but the code does not minified!

Any suggestion?


You should not be modifying the main.ts in this case.

Instead of using that setup, you should be using angular’s injectables correctly.

Remove it from the main.ts and move the service init to the ngModules provider array.
Then move the init method in the keycloakService to a proper constructor


Thank you for suggestion.

Already change main.ts to original version and change app.component.ts file with this implementation and now works fine :wink:


import { KeycloakService } from './keycloak.service';
declare let Keycloak: any;

export class MyApp {

  constructor(private kc: KeycloakService, public platform: Platform)

    this.platform.ready().then((readySource) => {
      //After keycloak init
            .then(() => {
              //After keycloak init
              if (this.kc.keycloakAuth.authenticated)
                  //user authenticated, continue app
            .catch((event) => 
                console.log("Keycloak init error." + event.error);  




I created a simple app Ionic2 with Keycloak integration https://github.com/sergeyrolich/ionic2-keycloak


Dpsmobile, could you share where you called the init method for keycloak service?