From 238880647e1b3bfb9286e95ef1856dcbe1739810 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Tue, 10 Feb 2026 17:49:41 +0530 Subject: [PATCH] simplify regex --- src/node/plugins/webFontsPlugin.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node/plugins/webFontsPlugin.ts b/src/node/plugins/webFontsPlugin.ts index e0bc31de6..fbe21f945 100644 --- a/src/node/plugins/webFontsPlugin.ts +++ b/src/node/plugins/webFontsPlugin.ts @@ -1,17 +1,17 @@ import type { Plugin } from 'vite' const webfontMarkerRE = - /\/(?:\*!?|\/) *webfont-marker-begin *(?:\*\/|\n|\r|\n\r|\r\n)([^]*?)\/(?:\*!?|\/) *webfont-marker-end *(?:\*\/|\n|\r|\n\r|\r\n|$)/ + /\/[\/*]!?\s*webfont-marker-begin(?:\s*\*\/)?([^]*?)\/[\/*]!?\s*webfont-marker-end(?:\s*\*\/)?/ export const webFontsPlugin = (enabled = false): Plugin => ({ name: 'vitepress:webfonts', enforce: 'pre', transform: { - filter: { id: /\/fonts\.s?css(?:$|\?)/ }, + filter: { id: /[\\/]fonts\.s?css(?:$|\?)/ }, handler(code) { if (enabled) { - return code.match(webfontMarkerRE)?.[1] + return code.match(webfontMarkerRE)?.[1].trim() } else { return code.replace(webfontMarkerRE, '') }