Skip to content

Commit d89e67c

Browse files
committed
perf: use code filter when processCSSVariables is disabled
1 parent a3be9a1 commit d89e67c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/fontless/src/vite.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,12 @@ export function fontless(_options?: FontlessOptions): Plugin {
7575
id: {
7676
include: [CSS_EXTENSIONS_RE, CSS_LANG_QUERY_RE, INLINE_STYLE_ID_RE],
7777
},
78+
code: {
79+
// Early return if no font-family is used in this CSS
80+
exclude: !options.processCSSVariables ? [/^(?!.*font-family\s*:).*$/s] : undefined,
81+
},
7882
},
7983
async handler(code, id) {
80-
// Early return if no font-family is used in this CSS
81-
if (!options.processCSSVariables && !code.includes('font-family:')) {
82-
return
83-
}
84-
8584
const s = await transformCSS(cssTransformOptions, code, id)
8685

8786
if (s.hasChanged()) {

0 commit comments

Comments
 (0)