I previously had the following folder structure for fonts
:
theme
assets
src
fonts
font-bold.eot
font-bold.svg
font-bold.otf
font-bold.woff
font-bold.woff2
font-bold.ttf
font-medium.eot
...
However, now I want to clean up the fonts
folder, so have now got the following:
theme
assets
src
fonts
font-bold
font-bold.eot
font-bold.svg
font-bold.otf
font-bold.woff
font-bold.woff2
font-bold.ttf
font-medium
font-medium.eot
...
I have basically grouped the fonts into folders.
Now, in my font-face
, I'm trying to search through each folder and generate the font family, but I'm currently a 404 error, full message:
/theme/assets/fonts/**/ net::ERR_ABORTED 404 (Not Found)
@each $key, $val in $font-families {
@font-face {
font-family: #{$key};
src: url('../../fonts/**/#{$val}.eot');
src: url('../../fonts/**/#{$val}.eot?#iefix') format('embedded-opentype'),
url('../../fonts/**/#{$val}.woff') format('woff'),
url('../../fonts/**/#{$val}.woff2') format('woff2'),
url('../../fonts/**/#{$val}.ttf') format('truetype'),
url('../../fonts/**/#{$val}.svg#sansationregular') format('svg');
font-style: normal;
font-display: swap;
}
}
Does **
not work in this sense as it does when importing
files? or am I missing something?
Edit:
I have the following set-up in my mixin
:
$font-families: (
'lemonmilk-regular': 'lemonmilk-regular/lemonmilk-regular',
'lemonmilk-light': 'lemonmilk-light/lemonmilk-light',
'lemonmilk-medium': 'lemonmilk-medium/lemonmilk-medium',
'lemonmilk-bold': 'lemonmilk-bold/lemonmilk-bold',
);
@each $key, $val in $font-families {
@font-face {
font-family: #{$key};
src: url('../../fonts/#{$val}.eot');
src: url('../../fonts/#{$val}.eot?#iefix') format('embedded-opentype'),
url('../../fonts/#{$val}.woff') format('woff'),
url('../../fonts/#{$val}.woff2') format('woff2'),
url('../../fonts/#{$val}.ttf') format('truetype'),
url('../../fonts/#{$val}.svg#sansationregular') format('svg');
font-style: normal;
font-display: swap;
}
}
Some of fonts seem to be showing up on the front end, but I also get a batch of 404 errors on the font files even though they exist?
question from:
https://stackoverflow.com/questions/65928741/sass-search-folders-within-folder-and-target-all-files