Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in production build: Index html generation failed [closed]

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

enter image description here

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

like image 449
Anuj TBE Avatar asked May 14 '21 15:05

Anuj TBE


People also ask

Why is my index not generating the HTML file?

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.

Why am I getting a build error in angular?

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.

Why does my build fail when I import fonts?

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.

How to solve error - CSS properties are generated with incorrect syntax?

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.


1 Answers

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.

like image 196
David B. Avatar answered Oct 17 '22 19:10

David B.