-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index html generation failed on ng build in Angular 12 #20804
Comments
Likely related to #20760, will need to take a look later to confirm if it’s the same root cause with data URIs. As a workaround you can disable critical CSS inlining https://angular.io/guide/workspace-config#optimization-configuration. |
@alan-agius4 Thank you, resolved. I can't believe how many hours I've wasted on this LMAO! inline styles and data URIs in particular (base64 images, etc.) break Angular 12's production build, wow. |
It appears that in your case the problem is that the CSS optimizer is incorrectly optimising media queries which is causing the CSS parser to fail. Opening @media{.page-break-after,.page-break-before{display:none}} Let's continue tracking this cssnano/cssnano#1105 |
I had this problem as well and it made no difference if I set Optimization to false in angular.json. It turned out as you mentioned that in the compiled .css I had a bad css row at the position the error was telling me: |
"rxjs" caused me the same problem, upgrade to "rxjs": "7.1.0", and fix errors, worked for me |
I know the issue is closed, but I was unable to reproduce an error with cssnano. I'm maintaining a component library which produces My solution was to decode
The application works fine except for the animation which is now broken in IE11. For more information see dso-toolkit/dso-toolkit#1152 |
disabling inlineCritical style optimization allows the build to succeed. The following config works for me however I'd like to now exactly why: |
@mtinnes yup, that fixes the problem. I had the same issue when upgrading some projects from Angular 11 to 12. In my case, the problem was base64 images. disabling inlineCritical or replacing data-uri images with image files resolved the issue. |
It works for me too (upgrade from ng11 to ng12). Can you explain in short what does this do in the end? |
Worked for me. This seems to be the best compromise; not disabling the optimization for all of them.
It only disables optimization for "inlineCritical", as per angular documentation: "Extract and inline critical CSS definitions to improve First Contentful Paint.". Here is an article explaining this in more detail. |
I got |
Index html generation failed. fix: inlineCritical :false |
My build failed with the same error. And it was because of cssnano/cssnano#1105 The CSS: @media all {
.page-break-after,
.page-break-before {
display: none;
}
} The |
I had the error:
Disabling 'inlineCritial' optimization works, but it's not a good solution cause it increases initial page load time.
After hours of searching, I found the line in my CSS which caused the trouble.
I changed it then to base64 encoding and it worked:
|
@tfrijsewijk @Schiepek Thanks for the tips, I run this issue today and your solution helps me fix the problem. |
If i add the Adyen CSS File: |
Getting the same issue using ClarityUI |
I have same issue (with missing ':'). The switching inline critical off works. however I dont see why is it happening. I dont have @media all.. only reference to @media (it appears in 2 different css files):
The app hasnt changed and worked in Angular 10 but not 12. |
Why is this issue closed? It doesn't appear to be fixed. For me it also happens with Apparently |
I agree with @DavidMarquezF , at least leave it opened with the link to cssnano issue...although workaround works, we lose some optimization features with it. |
this game can be played by two :) perhaps we should just open a new issue |
…ng critical CSS inling to fail Workaround for Critters as it doesn't work when `@media all {}` is minified to `@media {}`. Closes #20804
Hello ! :) |
I got the following error on ng build, with Angular 12 and Clarity 5.4.1: I fixed this by removing the double quotes from 10 lines in a copy of clr-ui.css (and using the copy): from: background-image: url("lots-o-characters") The double quotes appear to blow up the parser/optimizer or some part of the ng build, and removing the double quotes fixes that problem and doesn't appear to cause any others. |
@alan-agius4 thanks for the fix, but there is still the same issue with
our css looks like this:
@media print {
@page { ... }
}
.rule {
@import 'utils'
} it results in: @media print {
@page {
.rule { ... }
} I don't know if you'll be able to add another workaround for that or if i must use the
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report
Affected Package
Not sure which package is causing this error, here are the packages in use
Is this a regression?
Description
While running the build using
ng build
command, the build fails to generate the Index HTML file with the following errorMinimal Reproduction
Check the build log: https://github.com/anuj9196/quiz-app/runs/2589355739?check_suite_focus=true#step:7:56
To reproduce
npm install
ng build
Exception or Error
Your Environment
Angular Version:
Anything else relevant?
Setting
"optimization": false
in the build > options builds the project file but the build budget size is 2 MB more.The text was updated successfully, but these errors were encountered: