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 @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232- Fix class extraction followed by ` ( ` in Slim ([ #17278 ] ( https://github.com/tailwindlabs/tailwindcss/pull/17278 ) )
3333- Export ` PluginUtils ` from ` tailwindcss/plugin ` for compatibility with v3 ([ #17299 ] ( https://github.com/tailwindlabs/tailwindcss/pull/17299 ) )
3434- Increase Standalone hardware compatibility on macOS x64 builds ([ #17267 ] ( https://github.com/tailwindlabs/tailwindcss/pull/17267 ) )
35+ - Ensure that the CSS file rebuilds if a new CSS variable is used from templates
3536
3637## [ 4.0.14] - 2025-03-13
3738
Original file line number Diff line number Diff line change @@ -1303,11 +1303,11 @@ test(
13031303 ` ,
13041304 )
13051305
1306- fs . expectFileToContain (
1306+ // prettier-ignore
1307+ await fs . expectFileToContain (
13071308 './dist/out.css' ,
13081309 css `
1309- :root,
1310- :host {
1310+ :root, :host {
13111311 --color-blue-500: blue;
13121312 }
13131313 ` ,
Original file line number Diff line number Diff line change @@ -696,18 +696,21 @@ export async function compileAst(
696696 }
697697
698698 let didChange = defaultDidChange
699+ let didAddExternalVariable = false
699700 defaultDidChange = false
700701
701702 // Add all new candidates unless we know that they are invalid.
702703 let prevSize = allValidCandidates . size
703704 for ( let candidate of newRawCandidates ) {
704705 if ( ! designSystem . invalidCandidates . has ( candidate ) ) {
705706 if ( candidate [ 0 ] === '-' && candidate [ 1 ] === '-' ) {
706- designSystem . theme . markUsedVariable ( candidate )
707+ let didMarkVariableAsUsed = designSystem . theme . markUsedVariable ( candidate )
708+ didChange ||= didMarkVariableAsUsed
709+ didAddExternalVariable ||= didMarkVariableAsUsed
707710 } else {
708711 allValidCandidates . add ( candidate )
712+ didChange ||= allValidCandidates . size !== prevSize
709713 }
710- didChange ||= allValidCandidates . size !== prevSize
711714 }
712715 }
713716
@@ -725,7 +728,7 @@ export async function compileAst(
725728 // If no new ast nodes were generated, then we can return the original
726729 // CSS. This currently assumes that we only add new ast nodes and never
727730 // remove any.
728- if ( previousAstNodeCount === newNodes . length ) {
731+ if ( ! didAddExternalVariable && previousAstNodeCount === newNodes . length ) {
729732 compiled ??= optimizeAst ( ast , designSystem )
730733 return compiled
731734 }
Original file line number Diff line number Diff line change @@ -193,11 +193,13 @@ export class Theme {
193193 return `var(${ escape ( this . prefixKey ( themeKey ) ) } ${ fallback ? `, ${ fallback } ` : '' } )`
194194 }
195195
196- markUsedVariable ( themeKey : string ) {
196+ markUsedVariable ( themeKey : string ) : boolean {
197197 let key = unescape ( this . #unprefixKey( themeKey ) )
198198 let value = this . values . get ( key )
199- if ( ! value ) return
199+ if ( ! value ) return false
200+ let isUsed = value . options & ThemeOptions . USED
200201 value . options |= ThemeOptions . USED
202+ return ! isUsed
201203 }
202204
203205 resolve ( candidateValue : string | null , themeKeys : ThemeKey [ ] ) : string | null {
You can’t perform that action at this time.
0 commit comments