@@ -23,6 +23,47 @@ function* buildRegExps(context) {
23
23
let separator = context . tailwindConfig . separator
24
24
let variantGroupingEnabled = flagEnabled ( context . tailwindConfig , 'variantGrouping' )
25
25
26
+ let utility = regex . any ( [
27
+ // Arbitrary properties
28
+ / \[ [ ^ \s : ' " ] + : [ ^ \s \] ] + \] / ,
29
+
30
+ // Utilities
31
+ regex . pattern ( [
32
+ // Utility Name / Group Name
33
+ / - ? (?: \w + ) / ,
34
+
35
+ // Normal/Arbitrary values
36
+ regex . optional (
37
+ regex . any ( [
38
+ regex . pattern ( [
39
+ // Arbitrary values
40
+ / - \[ [ ^ \s : ] + \] / ,
41
+
42
+ // Not immediately followed by an `{[(`
43
+ / (? ! [ { ( [ ] ] ) / ,
44
+
45
+ // optionally followed by an opacity modifier
46
+ / (?: \/ [ ^ \s ' " \\ $ ] * ) ? / ,
47
+ ] ) ,
48
+
49
+ regex . pattern ( [
50
+ // Arbitrary values
51
+ / - \[ [ ^ \s ] + \] / ,
52
+
53
+ // Not immediately followed by an `{[(`
54
+ / (? ! [ { ( [ ] ] ) / ,
55
+
56
+ // optionally followed by an opacity modifier
57
+ / (?: \/ [ ^ \s ' " \\ $ ] * ) ? / ,
58
+ ] ) ,
59
+
60
+ // Normal values w/o quotes — may include an opacity modifier
61
+ / [ - \/ ] [ ^ \s ' " \\ $ = { ] * / ,
62
+ ] )
63
+ ) ,
64
+ ] ) ,
65
+ ] )
66
+
26
67
yield regex . pattern ( [
27
68
// Variants
28
69
'((?=((' ,
@@ -38,46 +79,15 @@ function* buildRegExps(context) {
38
79
// Important (optional)
39
80
/ ! ? / ,
40
81
41
- regex . any ( [
42
- // Arbitrary properties
43
- / \[ [ ^ \s : ' " ] + : [ ^ \s \] ] + \] / ,
44
-
45
- // Utilities
46
- regex . pattern ( [
47
- // Utility Name / Group Name
48
- variantGroupingEnabled ? / - ? (?: [ \w , ( ) ] + ) / : / - ? (?: \w + ) / ,
49
-
50
- // Normal/Arbitrary values
51
- regex . optional (
52
- regex . any ( [
53
- regex . pattern ( [
54
- // Arbitrary values
55
- / - \[ [ ^ \s : ] + \] / ,
56
-
57
- // Not immediately followed by an `{[(`
58
- / (? ! [ { ( [ ] ] ) / ,
59
-
60
- // optionally followed by an opacity modifier
61
- / (?: \/ [ ^ \s ' " \\ $ ] * ) ? / ,
62
- ] ) ,
63
-
64
- regex . pattern ( [
65
- // Arbitrary values
66
- / - \[ [ ^ \s ] + \] / ,
67
-
68
- // Not immediately followed by an `{[(`
69
- / (? ! [ { ( [ ] ] ) / ,
70
-
71
- // optionally followed by an opacity modifier
72
- / (?: \/ [ ^ \s ' " \\ $ ] * ) ? / ,
73
- ] ) ,
74
-
75
- // Normal values w/o quotes — may include an opacity modifier
76
- / [ - \/ ] [ ^ \s ' " \\ $ = { ] * / ,
77
- ] )
78
- ) ,
79
- ] ) ,
80
- ] ) ,
82
+ variantGroupingEnabled
83
+ ? regex . any ( [
84
+ // Or any of those things but grouped separated by commas
85
+ regex . pattern ( [ / \( / , utility , regex . zeroOrMore ( [ / , / , utility ] ) , / \) / ] ) ,
86
+
87
+ // Arbitrary properties, constrained utilities, arbitrary values, etc…
88
+ utility ,
89
+ ] )
90
+ : utility ,
81
91
] )
82
92
83
93
// 5. Inner matches
0 commit comments