1.7.0 fonts are corrupted after prod build
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
same issue on build and on ng serve got error
TypeError: undefined is not a function at Array.map (
I tried reproducing on Windows with 1.7.0 and could not. This is what I did:
ng new latest-project
cd latest-project
npm run build # builds with prod successfully
npm install --save font-awesome
# add "../node_modules/font-awesome/css/font-awesome.css" to `.angular-cli.json`
# as described in https://github.com/angular/angular-cli/wiki/stories-include-font-awesome
npm run build # builds successfully
npm start -- --prod # serve with prod, no error on browser
ng serve is fine for me, the error occurs when I run ng build --prod and use nginx or apache to serve the content.
Tried a production build ng build --prod with live-server and could also not reproduce the issue.
I didn't try this guy's build, but I see these same errors using ng serve using the same setup described here.
The issues started in 1.7.0-beta3 for me. Please let me know if you guys need any more info - this one is blocking me from upgrading (along with #9651) so I'd be glad to provide whatever info would help.
@MattMorrisDev That was caused by a bug in the betas that was fixed for the final release via https://github.com/angular/angular-cli/pull/9564 . The issue occurring here appears to be due to an interaction with nginx/apache.
Sorry, you're right. Got my versions/bugs mixed up.
This may be due to a caching issue. An old corrupt version of the file could either be cached local in the browser or in some intermediate cache.
Not related to caching, I always build a new docker container on deploy, and when I make it with 1.6.8 everything is fine, with 1.7.0 always messed up. On my work PC caching in disabled in the browser.
Seeing the same, moving back to 1.6.8. I also build a new container each time on ubuntu. So not related to caching or windows or mac.
Builiding with ng build --prod --aot false perhaps that makes a difference.
As we are unable to reproduce this, can you possibly put together a minimal reproduction that demonstrates the problem.
Also, does this occur with ng serve in production mode? Something else to try would be to do a production build and then use live-server (or similar) to test locally and reduce the complexity of the test case.
@import url("https://fonts.googleapis.com/css?family=Roboto:400,300,500,700"); in my theme css
seems to not load my fonts. I imported them manually in my index.html and the problem is gone.
This happens when using ng build --prod.
ng serve works fine.
@andjiev That's not related to this issue as the fonts in that case would not be processed by the CLI as it is an absolute URL. This issue may be more relevant: #9267. Also see my comment from that issue on why loading fonts in that manner is generally not a good idea: https://github.com/angular/angular-cli/issues/9267#issuecomment-363194043
Items that "might" help on repro. I am sorry I cannot easily break down the app, which is both large and proprietary.
A) This is occurring, in my example. using p-treetable (https://www.primefaces.org/primeng/#/treetable)
package.json:
{
"name": "xxxxxi",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.3",
"@angular/cdk": "^5.0.0-rc.1",
"@angular/common": "^5.0.3",
"@angular/compiler": "^5.0.3",
"@angular/compiler-cli": "^5.0.3",
"@angular/core": "^5.0.3",
"@angular/forms": "^5.0.3",
"@angular/http": "^5.0.3",
"@angular/material": "^5.0.0-rc.1",
"@angular/platform-browser": "^5.0.3",
"@angular/platform-browser-dynamic": "^5.0.3",
"@angular/platform-server": "^5.0.3",
"@angular/router": "^5.0.3",
"@swimlane/ngx-datatable": "=11.1.3",
"@types/file-saver": "0.0.1",
"angular-font-awesome": "^3.0.3",
"bootstrap": "^3.3.7",
"bootstrap-slider": "^9.8.1",
"chart.js": "^2.6.0",
"codelyzer": "^4.0.1",
"core-js": "^2.4.1",
"d3-ng2-service": "^1.19.0",
"dom-walk": "^0.1.1",
"eslint": "^4.4.1",
"file-saver": "^1.3.3",
"font-awesome": "^4.7.0",
"global": "^4.3.2",
"hammerjs": "^2.0.8",
"jquery": "^3.2.1",
"jstz": "^1.0.10",
"material-design-lite": "^1.3.0",
"min-document": "^2.19.0",
"moment": "^2.18.1",
"moment-timezone": "^0.5.13",
"ng2-charts": "^1.6.0",
"ng2-select-compat": "1.3.1",
"ng2-slideable-directive": "^1.0.13",
"ng2-slider-component": "^1.0.9",
"ngx-bootstrap": "^2.0.2",
"primeng": "^4.3.0",
"rxjs": "^5.5.2",
"tether": "^1.4.0",
"topojson": "^3.0.2",
"typescript": "^2.4.2",
"typings": "^2.1.1",
"xlsx": "^0.11.2",
"zone.js": "^0.8.14",
"@ng-bootstrap/ng-bootstrap": "^1.0.0"
},
"devDependencies": {
"@angular/cli": "=1.6.8",
"@angular/compiler-cli": "^4.0.0",
"@angular/language-service": "^4.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"@types/topojson": "^3.0.2",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.2",
"typescript": "~2.3.3",
"world-atlas": "^1.1.4"
}
}
Build is ng build --prod --aot false
angular-cli.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "dash-ui"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/bootstrap/dist/css/bootstrap-theme.min.css",
"../node_modules/@swimlane/ngx-datatable/release/index.css",
"../node_modules/@swimlane/ngx-datatable/release/themes/material.css",
"../node_modules/@swimlane/ngx-datatable/release/assets/icons.css",
"../node_modules/font-awesome/css/font-awesome.min.css",
"../node_modules/primeng/resources/primeng.min.css",
"../node_modules/primeng/resources/themes/omega/theme.css",
"styles.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/tether/dist/js/tether.min.js",
"../node_modules/moment/min/moment.min.js",
"../node_modules/moment-timezone/moment-timezone.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}
Note on above when failing the angular cli version in package.json was "@angular/cli": "^1.6.4",. Build today, 2-20-2018 which being a fresh npm install/ng build had pulled the latest 1.7.0
Same problem for me but with version 1.7.1, everything is fine with version 1.7.0.
Versions
Angular CLI: 1.7.1 Node: 8.9.4 OS: win32 x64 Angular: 5.2.6 ... animations, common, compiler, compiler-cli, core, forms ... http, platform-browser, platform-browser-dynamic, router
@angular/cli: 1.7.1 @angular-devkit/build-optimizer: 0.3.2 @angular-devkit/core: 0.3.2 @angular-devkit/schematics: 0.3.2 @ngtools/json-schema: 1.2.0 @ngtools/webpack: 1.10.1 @schematics/angular: 0.3.2 @schematics/package-update: 0.3.2 typescript: 2.6.2 webpack: 3.11.0
Same problem with 1.7.1 and latest semantic-ui
Failed to decode downloaded font: http://localhost:4200/icons.674f50d287a8c48dc19b.eot?#iefix)%20format(%27embedded-opentype%27),url(themes/default/assets/fonts/icons.woff2)%20format(%27woff2%27),url(themes/default/assets/fonts/icons.woff)%20format(%27woff%27),url(themes/default/assets/fonts/icons.ttf)%20format(%27truetype%27),url(themes/default/assets/fonts/icons.svg#icons)%20format(%27svg%27
OTS parsing error: invalid version tag
1.7.0 works just fine when running ng serve --aot
Can confirm on 1.7.* when "ng build --prod" is served through nginx. As above, clean docker image each time so definitely no caching issue. Reverting to 1.6.8 resolves.
Hmm I'm having a strange issue with fonts too since upgrading to 1.7.2 from 1.6.8, when I run --prod build my font imports seem to just disappear, I have moved them to index.html to get them working again, the strange thing is that it's only happening in one branch and I can't see any differences of note between the branches that would cause this, I haven't looked into it too much yet but it occurs running ng serve --prod as well as ng build --prod then using http-server to serve.
I'm experiencing similar issue after migrating from 1.6.8 to 1.7.3. Steps to reproduce:
ng new latest-project
cd latest-project
Download any font as a sample and put it into the project directory. I'll use Font Awesome as example. Then manually add @font-face definition to styles.css:
@font-face {
font-family: "Font Awesome";
src: url("./fa-solid-900.woff2") format("woff2");
font-weight: normal;
font-style: normal;
}
body {
font: "Font Awesome";
}
Then try to build the project:
ng build --prod
Date: 2018-03-15T08:46:41.758Z
Hash: ed0a71e03117b9c23e5c
Time: 4473ms
chunk {0} polyfills.bf95165a1d5098766b92.bundle.js (polyfills) 59.4 kB [initial] [rendered]
chunk {1} main.16bd2dbbc06007f15324.bundle.js (main) 154 kB [initial] [rendered]
chunk {2} styles.d9d6e24bded53673137d.bundle.css (styles) 137 bytes [initial] [rendered]
chunk {3} inline.318b50c57b4eba3d437b.bundle.js (inline) 796 bytes [entry] [rendered]
WARNING in Invalid font values at 11:1. Ignoring.
Fonts will not work, because they are removed from the output bundle. If I just downgrade @angular/cli to 1.6.8 in the same project without applying any changes to project and build it in the prod mode it's working fine.