Unable to import fonts using `@`
Answered
Anay-208 posted this in #help-forum
Anay-208OP
I want to use the
however, I get an error: Module not found:
Why is it added
@ for importing fonts like this:const monument = localFont({ src: '@/fonts/MonumentExtended-Regular.otf', variable: "--font-monument" })however, I get an error: Module not found:
Can't resolve './@/fonts/MonumentExtended-Regular.otf'Why is it added
./ add the start of the pathAnswered by joulev
the src string is simply a path string feeded to fs so you cant use absolute path import syntax here – it's simply not an import
6 Replies
@Anay-208 I want to use the `@` for importing fonts like this:
ts
const monument = localFont({ src: '@/fonts/MonumentExtended-Regular.otf', variable: "--font-monument" })
however, I get an error: Module not found: `Can't resolve './@/fonts/MonumentExtended-Regular.otf'`
Why is it added `./` add the start of the path
the src string is simply a path string feeded to fs so you cant use absolute path import syntax here – it's simply not an import
Answer
Anay-208OP
So what can I do of it? I need to use layout.tsx for a route, the problem is I’ll have it manually change the path for each.
You'll just have to update it manually
it's not like you're having 20+ files
maybe 3 or 4
Anay-208OP
I guess I'll do that. I dont really prefer hardcoding tho.