-
Notifications
You must be signed in to change notification settings - Fork 12k
Duplication of local fonts files imported in SCSS (reopen of #6599) #28882
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
Comments
I researched a little more and discover some things:
So the right thing to do would be to create a This still does not solve my original problem which is: how can I reference this font in the index.html file? It seems that it does not go through the same process as the CSS resource links, i.e., if i reference a font in Is there a way to link HTML links to this process? |
#26286 is likely relevant here, but I don't think we noticed a specific issue with font preloading. /cc @alan-agius4 |
The critical CSS inlining feature should be automatically adding preloads for the font file. Assuming it is in the critical path. Also of note is that v16 is no longer actively supported. Please consider upgrading to take advantage of the latest features and performance improvements in the newer versions. |
As @clydin mentioned, preloads are automatically added by the build system when critical CSS is enabled. Additionally, for Google and Adobe fonts, there's no need to save the CSS rules and files locally. Instead, during the build process, the CSS rule definitions are inlined. For more details, see Angular Workspace Configuration. |
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. |
Command
build
Is this a regression?
The previous version in which this bug was not present was
No response
Description
[reopen of #6599]
The problem
Two copies of the same font are appearing in the dist directory after
ng build
: One, located in the theassets/fonts folder
, other in the root ofdist
(actually, as this projects is using i18n, at the root of each language folder):The one at the "root" have a random string attached before the .woff2. Generated by a post-processor of CSS for what I understand. The bundled CSS in the
dist
folder references it.Besides the increase in size of the build output, one thing that is not working is preloading fonts in the
src/index.html
file. Usinghref="assets/fonts/font.woff2"
in a<link rel="preload">
tag will make the browser download this font, not use it, and download the version imported in the bundled CSS file in the root ofdist
.Expected behavior
I expected the bundled CSS to reference the font file inside the assets folder, not it to create another font in the root of the output files. Is there a configuration in
angular.json
that may prevent this behavior? Do I have to create a webpack configuration file?Minimal Reproduction
src/assets/fonts/font.woff2
;@font-face
in the formatsrc: url('assets/fonts/font.woff2')
in thesrc/styles.scss
file;ng build
command;My settings is closer to @ziemerz in #6599 as I am also using i18n. So changing
src: url('assets/fonts/font.woff2')
to an absolute path likesrc: url('/assets/fonts/font.woff2')
will not work for me.Reproduction repository: https://github.com/arturo32/angular-fonts-paths/tree/main
Exception or Error
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: