Upgraded the Angular 10 project to Angular 12. But now on running production build, it is giving error
Index HTML generation failed.
undefined:6:720366 missing '}'
ng build --configuration production --aot
It is very difficult to find the error because it points to the generated HTML file. Node log will no do much.
The content of index.html
<!doctype html>
<html lang="en">
<head>
<title>Quiz - Admin</title>
<base href="/">
<meta charset="utf-8">
</head>
<body>
<app></app>
</body>
</html>
While running the development build, locally does not give any error, even ng build
completed successfully
Please check the build pipeline here: https://github.com/anuj9196/quiz-app/runs/2589355739?check_suite_focus=true#step:7:56
The error is not in the index.html file that you see in the folder structure. It occurs on generating the final index.html. This is a compilation error probably in the css/scss files (as the typescript seem to compile correctly). Make sure you have all curly brackets } closed in your css files. ng build completes successfully.
The build error is related to the build budgets (but actually it should be a warning indeed if you compare the digits), and I changed them in the angular.json file: Could you check it on your side? You are correct. Increasing the budgets allowed me to build without error.
When you import fonts in your index.html the build could fail because of proxy issues (one possible reason). I moved the imports from the index.html to the styles.scss file.
Removing the string.unquote function might solve the error during compilation, however, it introduces another issue - CSS properties may be generated with incorrect syntax. I attached a project that shows this. In the attached archive, you can find the tst.scss file that uses the code we are using to generate CSS files.
The error is not in the index.html
file that you see in the folder structure. It occurs on generating the final index.html. This is a compilation error probably in the css/scss
files (as the typescript seem to compile correctly). Make sure you have all curly brackets }
closed in your css files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With