'Angular build - Index html generation failed. undefined:9:219187: property missing ':'
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! [email protected] build: `ng build --outputHashing=all "--configuration=prod"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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"
}
]
},
Solution 1:[1]
Just change `angular.json' file like this:
"configurations": {
"production": { // <=
"optimization": { //<= add this
"scripts": true,
"styles": {
"minify": true,
"inlineCritical": false
}
},
"budgets": [...]
Solution 2:[2]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | hazan kazim |
