I encountered numerous warning messages on my console when I built my application. However, these warnings are not rendering during local development.
Failed to decode downloaded font
Total of 1242 warnings
Perhaps it has something to do with my local font imports. In my setup, I have a directory that looks like this:
/my-app
/public
/fonts -- this is my target directly and all my fonts are here
/resources -- reactJS directory
/fonts -- fonts used in local development
/scss
Here's my font import inside my scss file
@font-face {
font-family: 'HelveticaNeue';
src: url('../fonts/helvetice-nueue/HelveticaNeueLight.eot');
src: url('../fonts/helvetice-nueue/HelveticaNeueLight.eot?#iefix') format('embedded-opentype'),
url('../fonts/helvetice-nueue/HelveticaNeueLight.woff2') format('woff2'),
url('../fonts/helvetice-nueue/HelveticaNeueLight.woff') format('woff'),
url('../fonts/helvetice-nueue/HelveticaNeueLight.ttf') format('truetype'),
url('../fonts/helvetice-nueue/HelveticaNeueLight.svg#HelveticaNeueLight') format('svg');
font-weight: 300;
font-style: normal;
font-display: swap;
}
I am using Vite with React and Laravel. Here's my setup inside vite.config
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/js/index.jsx',
],
refresh: true,
}),
react(),
],
});
When building, I noticed that the linter also produces these warnings (all of my font type imports have these warnings).
../fonts/helvetice-nueue/HelveticaNeueMedium_1.eot referenced in /var/www/sites/my-2023-app/resources/js/components/FreeGiftItem/FreeGiftCheckoutItem.scss didn't resolve at build time, it will remain unchanged to be resolved at runtime
ok, i suggested you use absolute path in your code.
this is copy answer from: link
so:
or (if you copied fonts to public directory):