From c1cefd7e2eabac2164465ed7f473070539e64397 Mon Sep 17 00:00:00 2001 From: Finn Date: Sat, 14 Sep 2024 19:39:48 +0100 Subject: [PATCH 1/4] fix: fixes an issue where the next-font plugin would not work on windows --- src/plugins/next-font/plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/next-font/plugin.ts b/src/plugins/next-font/plugin.ts index 433f763..3fd0a4c 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( From ccecafc50eec5fd330536a405cc707dd0eaa6877 Mon Sep 17 00:00:00 2001 From: Finn Date: Sat, 14 Sep 2024 20:35:20 +0100 Subject: [PATCH 2/4] fix: further fixes around windows paths --- src/plugins/next-font/plugin.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/next-font/plugin.ts b/src/plugins/next-font/plugin.ts index 3fd0a4c..bbacab9 100644 --- a/src/plugins/next-font/plugin.ts +++ b/src/plugins/next-font/plugin.ts @@ -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, }; } From e1cfec24d370591ad1f38d1ed9a97a8752c5afda Mon Sep 17 00:00:00 2001 From: Finn Date: Sat, 14 Sep 2024 20:38:03 +0100 Subject: [PATCH 3/4] chore: 2 spaces for tabs --- src/plugins/next-font/plugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/next-font/plugin.ts b/src/plugins/next-font/plugin.ts index bbacab9..e3f652e 100644 --- a/src/plugins/next-font/plugin.ts +++ b/src/plugins/next-font/plugin.ts @@ -92,8 +92,8 @@ export function vitePluginNextFont() { ); const fontPath = path - .join(importerDirPath, importerRelativeFontPath) - .replaceAll(path.win32.sep, path.posix.sep); + .join(importerDirPath, importerRelativeFontPath) + .replaceAll(path.win32.sep, path.posix.sep); if (devMode) { return { From 8be60a69f6abe96252a89596a1c5b257078af09d Mon Sep 17 00:00:00 2001 From: Finn Date: Sat, 14 Sep 2024 21:03:35 +0100 Subject: [PATCH 4/4] fix: remove @fs/ declaration --- src/plugins/next-font/local/get-font-face-declarations.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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}