Inside my main.scss
file, I am loading local fonts from the assets/styles/fonts
folder:
@font-face {
font-family: 'Opensans-Bold';
font-style: normal;
src: local('Opensans-Bold'), url(./fonts/OpenSans-Bold.ttf) format('truetype');
}
@font-face {
font-family: 'Opensans-Light';
font-style: normal;
src: local('Opensans-Light'), url(./fonts/OpenSans-Light.ttf) format('truetype');
}
Next, in my vite.config
setup, I make sure to include main.scss
:
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "@/assets/styles/main.scss";`
}
},
},
However, while most of the CSS from main.scss
is applied correctly, the fonts seem to be causing an issue. I receive the following error message:
downloadable font: download failed (font-family: "Opensans-Bold" style:normal weight:400 stretch:100 src index:1): status=2152398850 source: http://localhost:3000/fonts/OpenSans-Bold.ttf
Is this the right approach or should I consider a different method? (similar works with Vue-CLI)