angularangular12angularbuild

Angular 12 Index html generation failed error


Upgrading to angular 12 with the following command ng update @angular/core@12 @angular/cli@12 cause me to have the following error, when compiled with the --configuration production mode.

✖ Index html generation failed.
undefined:15:4027680: missing '}'

It's a duplicate of this question but wanted to post a proper question / answer since it will surely help others and I don't know when we will be able to post again on the thread since it was closed some days ago


Solution

  • In angular.json replace:

    "optimization": true 
    

    to:

    "optimization": { 
     "scripts": true, 
     "styles": { 
      "minify": true, 
      "inlineCritical": false 
     }
    }