File tree Expand file tree Collapse file tree 4 files changed +14
-8
lines changed Expand file tree Collapse file tree 4 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
37
37
- Fix class extraction followed by ` ( ` in Slim ([ #17278 ] ( https://github.com/tailwindlabs/tailwindcss/pull/17278 ) )
38
38
- Export ` PluginUtils ` from ` tailwindcss/plugin ` for compatibility with v3 ([ #17299 ] ( https://github.com/tailwindlabs/tailwindcss/pull/17299 ) )
39
39
- Increase Standalone hardware compatibility on macOS x64 builds ([ #17267 ] ( https://github.com/tailwindlabs/tailwindcss/pull/17267 ) )
40
+ - Ensure that the CSS file rebuilds if a new CSS variable is used from templates ([ #17301 ] ( https://github.com/tailwindlabs/tailwindcss/pull/17301 ) )
40
41
41
42
## [ 4.0.14] - 2025-03-13
42
43
Original file line number Diff line number Diff line change @@ -1303,11 +1303,11 @@ test(
1303
1303
` ,
1304
1304
)
1305
1305
1306
- fs . expectFileToContain (
1306
+ // prettier-ignore
1307
+ await fs . expectFileToContain (
1307
1308
'./dist/out.css' ,
1308
1309
css `
1309
- :root,
1310
- :host {
1310
+ :root, :host {
1311
1311
--color-blue-500: blue;
1312
1312
}
1313
1313
` ,
Original file line number Diff line number Diff line change @@ -696,18 +696,21 @@ export async function compileAst(
696
696
}
697
697
698
698
let didChange = defaultDidChange
699
+ let didAddExternalVariable = false
699
700
defaultDidChange = false
700
701
701
702
// Add all new candidates unless we know that they are invalid.
702
703
let prevSize = allValidCandidates . size
703
704
for ( let candidate of newRawCandidates ) {
704
705
if ( ! designSystem . invalidCandidates . has ( candidate ) ) {
705
706
if ( candidate [ 0 ] === '-' && candidate [ 1 ] === '-' ) {
706
- designSystem . theme . markUsedVariable ( candidate )
707
+ let didMarkVariableAsUsed = designSystem . theme . markUsedVariable ( candidate )
708
+ didChange ||= didMarkVariableAsUsed
709
+ didAddExternalVariable ||= didMarkVariableAsUsed
707
710
} else {
708
711
allValidCandidates . add ( candidate )
712
+ didChange ||= allValidCandidates . size !== prevSize
709
713
}
710
- didChange ||= allValidCandidates . size !== prevSize
711
714
}
712
715
}
713
716
@@ -725,7 +728,7 @@ export async function compileAst(
725
728
// If no new ast nodes were generated, then we can return the original
726
729
// CSS. This currently assumes that we only add new ast nodes and never
727
730
// remove any.
728
- if ( previousAstNodeCount === newNodes . length ) {
731
+ if ( ! didAddExternalVariable && previousAstNodeCount === newNodes . length ) {
729
732
compiled ??= optimizeAst ( ast , designSystem )
730
733
return compiled
731
734
}
Original file line number Diff line number Diff line change @@ -193,11 +193,13 @@ export class Theme {
193
193
return `var(${ escape ( this . prefixKey ( themeKey ) ) } ${ fallback ? `, ${ fallback } ` : '' } )`
194
194
}
195
195
196
- markUsedVariable ( themeKey : string ) {
196
+ markUsedVariable ( themeKey : string ) : boolean {
197
197
let key = unescape ( this . #unprefixKey( themeKey ) )
198
198
let value = this . values . get ( key )
199
- if ( ! value ) return
199
+ if ( ! value ) return false
200
+ let isUsed = value . options & ThemeOptions . USED
200
201
value . options |= ThemeOptions . USED
202
+ return ! isUsed
201
203
}
202
204
203
205
resolve (
You can’t perform that action at this time.
0 commit comments