-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I've setup a monorepo and located all my UI components in a shared package, packages/ui. This includes a utility class for importing fonts with next/font/google at packages/ui/lib/fonts.ts.
On startup, Storybook fails with the following error:
7:13:43 AM [vite] (client) Pre-transform error: Failed to load url
packages/ui/lib/fonts.ts","import":"Inter","arguments":[{"subsets":["latin"],"display":"swap","variable":"--font-
inter"}],"variableName":"inter"} (resolved id: packages/ui/lib/fonts.ts","import":"Inter","arguments":[{"subsets"
["latin"],"display":"swap","variable":"--font-inter"}],"variableName":"inter"}) in /<omitted>/sb-next-vite-
fonts/packages/ui/lib/fonts.ts. Does the file exist?
If I move the fonts.ts file into the same project as Storybook, e.g. at apps/storybook/lib/fonts.ts, then it works as expected.
Steps to reproduce the behavior
git clone https://github.com/jcarlson/sb-next-vite-fontscd sb-next-vite-fonts && pnpm installcd apps/storybook && pnpm run storybook- See error
Expected behavior
Next.js Font optimization should work correctly through library packages.
Environment
- OS: MacOS 15.6.1
- Node.js version: v22.19.0
- PNPM version: v10.11.0
Additional context
Bare bones repository to replicate this issue can be found here:
https://github.com/jcarlson/sb-next-vite-fonts
YaredFall
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working