@@ -22,7 +22,7 @@ import { substituteAtImports } from './at-import'
2222import { applyCompatibilityHooks } from './compat/apply-compat-hooks'
2323import type { UserConfig } from './compat/config/types'
2424import { type Plugin } from './compat/plugin-api'
25- import { applyVariant , compileCandidates } from './compile'
25+ import { compileCandidates } from './compile'
2626import { substituteFunctions } from './css-functions'
2727import * as CSS from './css-parser'
2828import { buildDesignSystem , type DesignSystem } from './design-system'
@@ -32,7 +32,7 @@ import { createCssUtility } from './utilities'
3232import { expand } from './utils/brace-expansion'
3333import { escape , unescape } from './utils/escape'
3434import { segment } from './utils/segment'
35- import { compoundsForSelectors , IS_VALID_VARIANT_NAME } from './variants'
35+ import { compoundsForSelectors , IS_VALID_VARIANT_NAME , substituteAtVariant } from './variants'
3636export type Config = UserConfig
3737
3838const IS_VALID_PREFIX = / ^ [ a - z ] + $ /
@@ -636,30 +636,7 @@ async function parseCss(
636636 firstThemeRule . nodes = [ context ( { theme : true } , nodes ) ]
637637 }
638638
639- // Replace the `@variant` at-rules with the actual variant rules.
640- if ( variantNodes . length > 0 ) {
641- for ( let variantNode of variantNodes ) {
642- // Starting with the `&` rule node
643- let node = styleRule ( '&' , variantNode . nodes )
644-
645- let variant = variantNode . params
646-
647- let variantAst = designSystem . parseVariant ( variant )
648- if ( variantAst === null ) {
649- throw new Error ( `Cannot use \`@variant\` with unknown variant: ${ variant } ` )
650- }
651-
652- let result = applyVariant ( node , variantAst , designSystem . variants )
653- if ( result === null ) {
654- throw new Error ( `Cannot use \`@variant\` with variant: ${ variant } ` )
655- }
656-
657- // Update the variant at-rule node, to be the `&` rule node
658- Object . assign ( variantNode , node )
659- }
660- features |= Features . Variants
661- }
662-
639+ features |= substituteAtVariant ( ast , designSystem )
663640 features |= substituteFunctions ( ast , designSystem )
664641 features |= substituteAtApply ( ast , designSystem )
665642
0 commit comments