Skip to content

[Bug] next/font not working on Windows #56

@izakgl

Description

@izakgl

Describe the bug

The next/font mock does not work on windows.

Steps to reproduce the behavior

I created a reproduction repository with minimal setup (bootstraping nextjs, storybook and then adding fonts): https://github.com/izakgl/nextjs-storybook-vite

Steps:

  1. Clone repo
  2. Install dependencies
  3. Run npm run storybook on a Windows machine
  4. Open a button story

Expected behavior

Story shows up and fonts work as expected.

Screenshots and/or logs

Image

The response for virtual inter is an empty object.
Image

Environment

  • OS: Windows
  • Browser (if applicable): All browsers

Additional context

I pinpointed the issue to be here:


Because it's taking separator from node:path package, which is \\ on Windows, it then fails to detect the correct file as vite is loading this from next/font/google/target.css with forward slash separators. If I hardcode / there, then this also works on Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions