Open arturo32 opened 15 hours ago
I researched a little more and discover some things:
So the right thing to do would be to create a src/fonts
folder and put my fonts there to avoid duplicated files. Ok.
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 index.html
with the path "fonts/my_font.woff2"
it will be not updated in the bundle as "my_font.adahjkdasd.woff2
".
Is there a way to link HTML links to this process?
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