4

I've built a mono-repository project with Turbo.

I have 2 Next.js projects in this repo.

I want to share font to each Next.js project.

apps
 |- next_project1
 |- next_project2
packages
 |- pulbic // I am not sure it is correct
 |- components
...

In packages/public, there are some .woff files.

And packages/components uses .woff from packages/public.

but it throws with

Failed to load resource: the server responded with a status of 404 (Not Found)

How can I share fonts to all projects under monorepo?

kyun
  • 9,710
  • 9
  • 31
  • 66
  • 3
    Did you find any solution for this? I am facing the same here. – Metarat Oct 11 '22 at 14:12
  • There is no direct solution for this, because nextjs cannot resolve fonts that are not shipped with next in the public folder (first problem) and at the same time the @next/font package does not resolve fonts from workspace packages as well. What you can do is use tsup in your ui package to actually ship the **compiled** ui library, so that tsup will handle the fonts and nextjs will just consume the compiled components instead of simply symlinking the package and compiling it. This is the same approach used with tailwind, if you want to do a fast search for it. – briosheje Jan 26 '23 at 11:20
  • Hope it helps you guys! Just use css url() https://stackoverflow.com/a/76072188/10937596 – Vlad Rose Apr 21 '23 at 11:12

0 Answers0