Angular build - Index html generation failed. undefined:9:219187: property missing ':'

Viewed 567

I have an Angular App that doesn't seem to build with the prod configuration. I get the following error:

 Index html generation failed.
 undefined:9:219187: property missing ':'
 npm ERR! code ELIFECYCLE
 npm ERR! errno 1
 npm ERR! JI.Infopool.WebApp@0.0.0 build: `ng build --outputHashing=all "--configuration=prod"`
 npm ERR! Exit status 1
 npm ERR!
 npm ERR! Failed at the JI.Infopool.WebApp@0.0.0 build script.
 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

The normal build works fine and I don't think that I changed any of the run configurations. I couldn't find anything useful in the log file either. Here's the config in the angular.json file:

"prod": {
          "baseHref": "/myApp/",
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true,
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ]
        },
2 Answers

Just change `angular.json' file like this:

      "configurations": {
            "production": { // <=
              "optimization": { //<= add this 
                "scripts": true, 
                "styles": { 
                 "minify": true, 
                 "inlineCritical": false 
                }
               },
              "budgets": [...]

there are some reasons may not generate the index file cause of minificaion on of errored css and script files or you may access the commonjs file. or external files like google fonts all are require internet at build time.

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

please refer this link for more details https://angular.io/guide/workspace-config#optimization-configuration

Related