Skip to content

Commit 368eb80

Browse files
committed
only stringify the value when something changed
1 parent c281426 commit 368eb80

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/tailwindcss/src/signatures.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const computeUtilitySignature = new DefaultMap<
115115
// Handle declarations
116116
if (node.kind === 'declaration' && node.value !== undefined) {
117117
if (node.value.includes('var(')) {
118+
let changed = false
118119
let valueAst = ValueParser.parse(node.value)
119120

120121
let seen = new Set<string>()
@@ -157,6 +158,7 @@ export const computeUtilitySignature = new DefaultMap<
157158
// More than 1 argument means that a fallback is already present
158159
if (valueNode.nodes.length === 1) {
159160
// Inject the fallback value into the variable lookup
161+
changed = true
160162
valueNode.nodes.push(...ValueParser.parse(`,${variableValue}`))
161163
}
162164
}
@@ -169,14 +171,15 @@ export const computeUtilitySignature = new DefaultMap<
169171
let nodeAsString = ValueParser.toCss(valueNode.nodes) // This could include more than just the variable
170172
let constructedValue = `${valueNode.nodes[0].value},${variableValue}`
171173
if (nodeAsString === constructedValue) {
174+
changed = true
172175
replaceWith(ValueParser.parse(variableValue))
173176
}
174177
}
175178
}
176179
})
177180

178181
// Replace the value with the new value
179-
node.value = ValueParser.toCss(valueAst)
182+
if (changed) node.value = ValueParser.toCss(valueAst)
180183
}
181184

182185
// Very basic `calc(…)` constant folding to handle the spacing scale

0 commit comments

Comments
 (0)