angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

1.7.0 fonts are corrupted after prod build

Open MateEke opened this issue 8 years ago • 64 comments

Versions

Angular CLI: 1.7.0 Node: 8.9.1 OS: win32 x64 Angular: 5.2.5 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router

@angular/cli: 1.7.0 @angular-devkit/build-optimizer: 0.3.1 @angular-devkit/core: 0.3.1 @angular-devkit/schematics: 0.3.1 @ngtools/json-schema: 1.2.0 @ngtools/webpack: 1.10.0 @schematics/angular: 0.3.1 @schematics/package-update: 0.3.1 typescript: 2.7.1 webpack: 3.11.0

Repro steps

  • Install @angular/cli: 1.7.0
  • import fontawesome in .angular-cli.json or in styles.scss
  • run ng build --prod

Observed behavior

Failed to decode downloaded font: http://***/fontawesome-webfont.af7ae505a9eed503f8b8.woff2?v=4.7.0 OTS parsing error: invalid version tag

Desired behavior

FontAwesome icons works fine

Mention any other details that might be useful (optional)

With cli 1.6.8 everything is OK

MateEke avatar Feb 16 '18 10:02 MateEke

I'm facing this issue too.

But is weird because in my case the icons shows partially, just a couple of them are not being rendered and the worst part is that my images are not being rendered in any way and the console doesn't show any issue related with the images.

Also, when I run ng build --prod I lose my images and the FontAwesome.

asfo avatar Mar 21 '18 16:03 asfo

@anton-gorbikov Did you ever find a solution to this? I'm getting the "Invalid font values" warning as well, except I'm not even sure what fonts it is affecting, I'm assuming font awesome.

bluecaret avatar Apr 05 '18 20:04 bluecaret

@bluecaret No, I have no solution/workaround for this issue. In my current project it affects all fonts, not just Font Awesome. So I just rolled back ng-cli to version 1.6.8

anton-gorbikov avatar Apr 06 '18 09:04 anton-gorbikov

Just tried with 1.7.4 (released 2 days ago) - issue is still present.

fergalmoran avatar Apr 07 '18 09:04 fergalmoran

I had this problem in combination with nginx. When I added the following line to server part in nginx configuartion file it was resolved: location ~* \.(eot|otf|ttf|woff|woff2)$ { root /usr/share/nginx/html; }

bart-kors avatar Apr 10 '18 11:04 bart-kors

I am seeing this too.

Angular CLI: 1.7.4 Node: 8.9.1 OS: win32 x64 Angular: 5.2.10

Running: ng build --prod --output-hashing=all

WARNING in Invalid font values at 1405:2. Ignoring.

ImranAhmed avatar Apr 30 '18 11:04 ImranAhmed

I can confirm this too. Angular CLI: 1.7.4 Node: 8.4.0 OS: windows 10 x64 Angular: 5.2.10 Server: IIS 8.5 Running: ng build --prod everything build fine, so errors or warnings Publish the build to my server and fonts are all messed up.

If I build with angular/cli 1.6.8, everything is fine. if I run ng server with angular/[email protected] everything is fine too.

Currently I have to use angular/[email protected] to build and publish. Hopefully update to angular/cli will fix the issue

ghost avatar May 01 '18 21:05 ghost

I managed to get it working by downloading fonts locally instead of referencing remote web location. The warning during build still appears, but the fonts are working in 90% of application parts.

tmofardin avatar May 02 '18 06:05 tmofardin

@bart-kors suggestion above works for those using nginx.

fergalmoran avatar May 02 '18 15:05 fergalmoran

referencing locally works for me too. I removed remote references and added to my .angular-cli.json file in the styles section "styles": [ "../node_modules/material-design-icons/iconfont/material-icons.css", "../node_modules/font-awesome/css/font-awesome.css", "app/styles.scss" ], running: ng serve no issues and: ng build --prod no issues on server too

ghost avatar May 02 '18 17:05 ghost

@anton-gorbikov I see the same behavior that you are when I import google fonts because the fonts are defined using font-face. Simply making the changes below fixed the issue for me. Before:

body {
    font: 14px 'Open Sans';
}

After:

body {
    font-size: 14px;
    font-family: 'Open Sans';
}

pderks avatar May 02 '18 20:05 pderks

I've just updated my project to Angular v6 and CLI v6 and I am no longer seeing the font warning issue.

Angular CLI: 6.0.0 Node: 8.9.4 OS: win32 x64 Angular: 6.0.0 ... animations, cdk, cli, common, compiler, compiler-cli, core ... forms, http, language-service, material, platform-browser ... platform-browser-dynamic, platform-server, router

ImranAhmed avatar May 06 '18 14:05 ImranAhmed

Today I've updated project to Angular and CLI to v6 and it didn't fix the issue. However changing font to font-size + font-family manually fixes the problem. Thanks a lot @pderks !

anton-gorbikov avatar May 07 '18 14:05 anton-gorbikov

@anton-gorbikov , yes, you are right. I've just checked again and the issue is still there in angular v6. I must have ran it with the aot flag, thanks for the clarification.

ImranAhmed avatar May 07 '18 15:05 ImranAhmed

The issue is still there in v6.

@bart-kors This solution works for me, thank you!

MateEke avatar May 10 '18 12:05 MateEke

I'm also using nginx, but the @bart-kors solution didn't fix, just because the problem is that I don't even have the @import of the font from the CDN in the prod build, and I don't get any warning, it just removes it.

btw: i'm using SCSS

lucax88x avatar May 12 '18 16:05 lucax88x

I have the same problem with font-awesome (style - scss, Angular-cli - 1.7.4, nginx). Which is the best way to solve this issue?

Spri85 avatar May 23 '18 06:05 Spri85

@Spri85 What kind of problems do you have? Have you tried downloading them locally?

tmofardin avatar May 23 '18 07:05 tmofardin

Hello,

Yes, I tried download locally, but I got error that can’t find file .woff2.

The error was only when I tried run build prod in nginx.

But when I changed path

From: "../node_modules/font-awesome/css/font-awesome.css"

To: "../node_modules/font-awesome/scss/font-awesome.scss"

It became to normal and works fine.

Thank you for help

Best regards,

Paranin Viktor

From: Toni Mofardin [mailto:[email protected]] Sent: Wednesday, May 23, 2018 10:44 AM To: angular/angular-cli [email protected] Cc: Viktor [email protected]; Comment [email protected] Subject: Re: [angular/angular-cli] 1.7.0 fonts are corrupted after prod build (#9648)

What kind of problems do you have? Have you tried downloading them locally?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/9648#issuecomment-391252117 , or mute the thread https://github.com/notifications/unsubscribe-auth/ALwLX-63tMlhHTEyUirAA85McI377yz4ks5t1RNDgaJpZM4SIIWb .

Spri85 avatar May 23 '18 08:05 Spri85

In an Angular 6 project you can get past this if you set optimization to false in angular.json file.

image

The problem is when it spits out the warning its actually very difficult to trace it back to the exact css style that it is complaining about because the output files have been optimized.

ImranAhmed avatar May 23 '18 15:05 ImranAhmed