@@ -346,16 +346,22 @@ function changeAffectsFile(change: string, files: string[]): boolean {
346
346
347
347
// We need to add parent directories to the watcher:
348
348
// https://github.com/microsoft/vscode/issues/60813
349
- function getWatchPatternsForFile ( file : string ) : string [ ] {
349
+ function getWatchPatternsForFile ( file : string , root : string ) : string [ ] {
350
350
let tmp : string
351
351
let dir = path . dirname ( file )
352
352
let patterns : string [ ] = [ file , dir ]
353
+ if ( dir === root ) {
354
+ return patterns
355
+ }
353
356
while ( true ) {
354
357
dir = path . dirname ( ( tmp = dir ) )
355
358
if ( tmp === dir ) {
356
359
break
357
360
} else {
358
361
patterns . push ( dir )
362
+ if ( dir === root ) {
363
+ break
364
+ }
359
365
}
360
366
}
361
367
return patterns
@@ -440,8 +446,8 @@ async function createProjectService(
440
446
deps = getModuleDependencies ( projectConfig . configPath )
441
447
} catch { }
442
448
watchPatterns ( [
443
- ...getWatchPatternsForFile ( projectConfig . configPath ) ,
444
- ...deps . flatMap ( ( dep ) => getWatchPatternsForFile ( dep ) ) ,
449
+ ...getWatchPatternsForFile ( projectConfig . configPath , projectConfig . folder ) ,
450
+ ...deps . flatMap ( ( dep ) => getWatchPatternsForFile ( dep , projectConfig . folder ) ) ,
445
451
] )
446
452
}
447
453
@@ -459,7 +465,7 @@ async function createProjectService(
459
465
let file = normalizePath ( change . file )
460
466
461
467
let isConfigFile = changeAffectsFile ( file , [ projectConfig . configPath ] )
462
- let isDependency = changeAffectsFile ( change . file , state . dependencies ?? [ ] )
468
+ let isDependency = changeAffectsFile ( file , state . dependencies ?? [ ] )
463
469
let isPackageFile = minimatch ( file , `**/${ PACKAGE_LOCK_GLOB } ` , { dot : true } )
464
470
465
471
if ( ! isConfigFile && ! isDependency && ! isPackageFile ) continue
@@ -564,7 +570,7 @@ async function createProjectService(
564
570
throw new SilentError ( 'No config file found.' )
565
571
}
566
572
567
- watchPatterns ( getWatchPatternsForFile ( configPath ) )
573
+ watchPatterns ( getWatchPatternsForFile ( configPath , projectConfig . folder ) )
568
574
569
575
const pnpPath = findUp . sync (
570
576
( dir ) => {
@@ -576,7 +582,7 @@ async function createProjectService(
576
582
if ( findUp . sync . exists ( pnpFile ) ) {
577
583
return pnpFile
578
584
}
579
- if ( dir === folder ) {
585
+ if ( dir === path . normalize ( folder ) ) {
580
586
return findUp . stop
581
587
}
582
588
} ,
@@ -1062,7 +1068,11 @@ async function createProjectService(
1062
1068
// }
1063
1069
state . dependencies = getModuleDependencies ( state . configPath )
1064
1070
// chokidarWatcher?.add(state.dependencies)
1065
- watchPatterns ( ( state . dependencies ?? [ ] ) . flatMap ( ( dep ) => getWatchPatternsForFile ( dep ) ) )
1071
+ watchPatterns (
1072
+ ( state . dependencies ?? [ ] ) . flatMap ( ( dep ) =>
1073
+ getWatchPatternsForFile ( dep , projectConfig . folder )
1074
+ )
1075
+ )
1066
1076
1067
1077
state . configId = getConfigId ( state . configPath , state . dependencies )
1068
1078
@@ -1515,7 +1525,7 @@ async function getConfigFileFromCssFile(cssFile: string): Promise<string | null>
1515
1525
if ( ! match ) {
1516
1526
return null
1517
1527
}
1518
- return path . resolve ( path . dirname ( cssFile ) , match . groups . config . slice ( 1 , - 1 ) )
1528
+ return normalizePath ( path . resolve ( path . dirname ( cssFile ) , match . groups . config . slice ( 1 , - 1 ) ) )
1519
1529
}
1520
1530
1521
1531
function getPackageRoot ( cwd : string , rootDir : string ) {
@@ -1526,7 +1536,7 @@ function getPackageRoot(cwd: string, rootDir: string) {
1526
1536
if ( findUp . sync . exists ( pkgJson ) ) {
1527
1537
return pkgJson
1528
1538
}
1529
- if ( dir === rootDir ) {
1539
+ if ( dir === path . normalize ( rootDir ) ) {
1530
1540
return findUp . stop
1531
1541
}
1532
1542
} ,
@@ -1606,7 +1616,7 @@ class TW {
1606
1616
let ignore = globalSettings . tailwindCSS . files . exclude
1607
1617
let configFileOrFiles = globalSettings . tailwindCSS . experimental . configFile
1608
1618
1609
- let base = normalizeFileNameToFsPath ( this . initializeParams . rootPath )
1619
+ let base = normalizePath ( normalizeFileNameToFsPath ( this . initializeParams . rootPath ) )
1610
1620
let cssFileConfigMap : Map < string , string > = new Map ( )
1611
1621
let configTailwindVersionMap : Map < string , string > = new Map ( )
1612
1622
@@ -1640,7 +1650,7 @@ class TW {
1640
1650
( [ relativeConfigPath , relativeDocumentSelectorOrSelectors ] ) => {
1641
1651
return {
1642
1652
folder : base ,
1643
- configPath : path . resolve ( userDefinedConfigBase , relativeConfigPath ) ,
1653
+ configPath : normalizePath ( path . resolve ( userDefinedConfigBase , relativeConfigPath ) ) ,
1644
1654
documentSelector : [ ] . concat ( relativeDocumentSelectorOrSelectors ) . map ( ( selector ) => ( {
1645
1655
priority : DocumentSelectorPriority . USER_CONFIGURED ,
1646
1656
pattern : normalizePath ( path . resolve ( userDefinedConfigBase , selector ) ) ,
0 commit comments