How to fix Angular "ng build" not producing index.html
Unless you have errors in your build (which is clearly visible from looking at the ng build
output), the reason why ng build
doesn’t produce an index.html
is that the resulting bundle exceeds the maximum allowed size.
This is evident from the output such as
Error: bundle initial exceeded maximum budget. Budget 1.00 MB was not met by 3.73 kB with a total of 1.00 MB.
In order to fix it, either shrink your application by removing unneeded features or libraries or splitting off certain features into extra modules or, at least temporarily, increase the allowable budget.
In order to do that, open angular.json
and look for the "budgets": {...
section:
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
Increase the maximumError
value for "type": "initial"
(the first entry in the list shown above).
For example, you could increase it from 1mb
to 4mb
to fix your build.
After that, run your ng build
command again and index.html
should be generated.
Be aware, however, that having huge JS bundles can really slow down your web application especially for mobile users.