diff --git a/src/plugins/next-font/local/get-font-face-declarations.ts b/src/plugins/next-font/local/get-font-face-declarations.ts index 4d35f08..04d9228 100644 --- a/src/plugins/next-font/local/get-font-face-declarations.ts +++ b/src/plugins/next-font/local/get-font-face-declarations.ts @@ -72,7 +72,7 @@ export async function getFontFaceDeclarations(options: LoaderOptions) { if ("fontReferenceId" in localFontSrc) { return dedent`@font-face { font-family: ${id}; - src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs${localFontSrc.fontPath}`}) + src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `${localFontSrc.fontPath}`}) ${fontDeclarations} }`; } @@ -86,7 +86,7 @@ export async function getFontFaceDeclarations(options: LoaderOptions) { .map((font) => { return dedent`@font-face { font-family: ${id}; - src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs${font.path.fontPath}`}); + src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `${font.path.fontPath}`}); ${font.weight ? `font-weight: ${font.weight};` : ""} ${font.style ? `font-style: ${font.style};` : ""} ${fontDeclarations} diff --git a/src/plugins/next-font/plugin.ts b/src/plugins/next-font/plugin.ts index 433f763..e3f652e 100644 --- a/src/plugins/next-font/plugin.ts +++ b/src/plugins/next-font/plugin.ts @@ -67,7 +67,7 @@ export function vitePluginNextFont() { let fontFaceDeclaration: FontFaceDeclaration | undefined; - const pathSep = path.sep; + const pathSep = path.posix.sep; if ( sourceWithoutQuery.endsWith( @@ -91,11 +91,13 @@ export function vitePluginNextFont() { fontExtension, ); - const fontPath = path.join(importerDirPath, importerRelativeFontPath); + const fontPath = path + .join(importerDirPath, importerRelativeFontPath) + .replaceAll(path.win32.sep, path.posix.sep); if (devMode) { return { - fontPath: path.join(cwd, fontPath), + fontPath: fontPath, fontReferenceId: undefined, }; }