Skip to content

Commit

Permalink
fix(transform): only add @font-face for first font in list
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Feb 21, 2024
1 parent 3773a9d commit 0493d36
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plugins/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ export const FontFamilyInjectionPlugin = (options: FontFamilyInjectionPluginOpti
enter (node) {
if (node.property !== 'font-family' || this.atrule?.name === 'font-face') { return }

for (const fontFamily of extractFontFamilies(node)) {
if (processedFontFamilies.has(fontFamily) || existingFontFamilies.has(fontFamily)) continue
// Only add @font-face for the first font-family in the list
const [fontFamily] = extractFontFamilies(node)
if (fontFamily && !processedFontFamilies.has(fontFamily) && !existingFontFamilies.has(fontFamily)) {
processedFontFamilies.add(fontFamily)
promises.push(addFontFaceDeclaration(fontFamily))
}
Expand Down

0 comments on commit 0493d36

Please sign in to comment.