File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
packages/tailwindcss-class-names/src Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -114,27 +114,34 @@ export default async function getClassNames(
114114
115115 let watcher
116116 function watch ( files = [ ] ) {
117- if ( watcher ) watcher . close ( )
117+ unwatch ( )
118118 watcher = chokidar
119- . watch ( [ CONFIG_GLOB , ... files ] , { cwd } )
119+ . watch ( files , { cwd } )
120120 . on ( 'change' , handleChange )
121121 . on ( 'unlink' , handleChange )
122122 }
123+ function unwatch ( ) {
124+ if ( watcher ) {
125+ watcher . close ( )
126+ }
127+ }
123128
124129 async function handleChange ( ) {
125- const prevDeps = result ? result . dependencies : [ ]
130+ const prevDeps = result ? [ result . configPath , ... result . dependencies ] : [ ]
126131 try {
127132 result = await run ( )
128133 } catch ( error ) {
129134 if ( error instanceof TailwindConfigError ) {
130135 onChange ( { error } )
131136 } else {
137+ unwatch ( )
132138 onChange ( null )
133139 }
134140 return
135141 }
136- if ( ! arraysEqual ( prevDeps , result . dependencies ) ) {
137- watch ( result . dependencies )
142+ const newDeps = [ result . configPath , ...result . dependencies ]
143+ if ( ! arraysEqual ( prevDeps , newDeps ) ) {
144+ watch ( newDeps )
138145 }
139146 onChange ( result )
140147 }
@@ -143,11 +150,10 @@ export default async function getClassNames(
143150 try {
144151 result = await run ( )
145152 } catch ( _ ) {
146- watch ( )
147153 return null
148154 }
149155
150- watch ( result . dependencies )
156+ watch ( [ result . configPath , ... result . dependencies ] )
151157
152158 return result
153159}
You can’t perform that action at this time.
0 commit comments