@@ -23,7 +23,7 @@ import { Theme, ThemeOptions, type ThemeKey } from './theme'
2323import { Utilities , createUtilities , withAlpha } from './utilities'
2424import { DefaultMap } from './utils/default-map'
2525import { extractUsedVariables } from './utils/variables'
26- import { Variants , createVariants } from './variants'
26+ import { Variants , createVariants , substituteAtVariant } from './variants'
2727
2828export const enum CompileAstFlags {
2929 None = 0 ,
@@ -77,15 +77,21 @@ export function buildDesignSystem(theme: Theme): DesignSystem {
7777 return new DefaultMap < Candidate > ( ( candidate ) => {
7878 let ast = compileAstNodes ( candidate , designSystem , flags )
7979
80- // Arbitrary values (`text-[theme(--color-red-500)]`) and arbitrary
81- // properties (`[--my-var:theme(--color-red-500)]`) can contain function
82- // calls so we need evaluate any functions we find there that weren't in
83- // the source CSS.
8480 try {
81+ // Arbitrary values (`text-[theme(--color-red-500)]`) and arbitrary
82+ // properties (`[--my-var:theme(--color-red-500)]`) can contain function
83+ // calls so we need evaluate any functions we find there that weren't in
84+ // the source CSS.
8585 substituteFunctions (
8686 ast . map ( ( { node } ) => node ) ,
8787 designSystem ,
8888 )
89+
90+ // JS plugins might contain an `@variant` inside a generated utility
91+ substituteAtVariant (
92+ ast . map ( ( { node } ) => node ) ,
93+ designSystem ,
94+ )
8995 } catch ( err ) {
9096 // If substitution fails then the candidate likely contains a call to
9197 // `theme()` that is invalid which may be because of incorrect usage,
0 commit comments