@@ -68,6 +68,7 @@ import { doCodeActions } from 'tailwindcss-language-service/src/codeActions/code
6868import { getDocumentColors } from 'tailwindcss-language-service/src/documentColorProvider'
6969import { fromRatio , names as namedColors } from '@ctrl/tinycolor'
7070import { debounce } from 'debounce'
71+ import { getModuleDependencies } from './util/getModuleDependencies'
7172// import postcssLoadConfig from 'postcss-load-config'
7273
7374const CONFIG_FILE_GLOB = 'tailwind.config.{js,cjs}'
@@ -123,6 +124,12 @@ function deletePropertyPath(obj: any, path: string | string[]): void {
123124 delete obj [ path . pop ( ) ]
124125}
125126
127+ function getConfigId ( configPath : string , configDependencies : string [ ] ) : string {
128+ return JSON . stringify (
129+ [ configPath , ...configDependencies ] . map ( ( file ) => [ file , fs . statSync ( file ) . mtimeMs ] )
130+ )
131+ }
132+
126133interface ProjectService {
127134 state : State
128135 tryInit : ( ) => Promise < void >
@@ -335,7 +342,8 @@ async function createProjectService(
335342 setPnpApi ( pnpApi )
336343 }
337344
338- const configModified = fs . statSync ( configPath ) . mtimeMs
345+ const configDependencies = getModuleDependencies ( configPath )
346+ const configId = getConfigId ( configPath , configDependencies )
339347 const configDir = path . dirname ( configPath )
340348 let tailwindcss : any
341349 let postcss : any
@@ -372,7 +380,7 @@ async function createProjectService(
372380 postcssVersion === state . modules . postcss . version &&
373381 tailwindcssVersion === state . modules . tailwindcss . version &&
374382 configPath === state . configPath &&
375- configModified === state . configModified
383+ configId === state . configId
376384 ) {
377385 return
378386 }
@@ -452,7 +460,6 @@ async function createProjectService(
452460 }
453461
454462 state . configPath = configPath
455- state . configModified = configModified
456463 state . modules = {
457464 tailwindcss : { version : tailwindcssVersion , module : tailwindcss } ,
458465 postcss : { version : postcssVersion , module : postcss } ,
@@ -593,18 +600,14 @@ async function createProjectService(
593600 return exports
594601 } )
595602
596- hook . watch ( )
597603 let config
598604 try {
599605 config = __non_webpack_require__ ( state . configPath )
600606 } catch ( error ) {
601- hook . unwatch ( )
602607 hook . unhook ( )
603608 throw error
604609 }
605610
606- hook . unwatch ( )
607-
608611 let postcssResult : Result
609612 try {
610613 postcssResult = await postcss
@@ -656,9 +659,12 @@ async function createProjectService(
656659 if ( state . dependencies ) {
657660 watcher . unwatch ( state . dependencies )
658661 }
659- state . dependencies = hook . deps
662+ state . dependencies = getModuleDependencies ( state . configPath )
663+ console . log ( { deps : state . dependencies } )
660664 watcher . add ( state . dependencies )
661665
666+ state . configId = getConfigId ( state . configPath , state . dependencies )
667+
662668 state . config = resolveConfig . module ( config )
663669 state . separator = typeof userSeperator === 'string' ? userSeperator : ':'
664670 state . plugins = await getPlugins ( config )
0 commit comments