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(
114
114
115
115
let watcher
116
116
function watch ( files = [ ] ) {
117
- if ( watcher ) watcher . close ( )
117
+ unwatch ( )
118
118
watcher = chokidar
119
- . watch ( [ CONFIG_GLOB , ... files ] , { cwd } )
119
+ . watch ( files , { cwd } )
120
120
. on ( 'change' , handleChange )
121
121
. on ( 'unlink' , handleChange )
122
122
}
123
+ function unwatch ( ) {
124
+ if ( watcher ) {
125
+ watcher . close ( )
126
+ }
127
+ }
123
128
124
129
async function handleChange ( ) {
125
- const prevDeps = result ? result . dependencies : [ ]
130
+ const prevDeps = result ? [ result . configPath , ... result . dependencies ] : [ ]
126
131
try {
127
132
result = await run ( )
128
133
} catch ( error ) {
129
134
if ( error instanceof TailwindConfigError ) {
130
135
onChange ( { error } )
131
136
} else {
137
+ unwatch ( )
132
138
onChange ( null )
133
139
}
134
140
return
135
141
}
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 )
138
145
}
139
146
onChange ( result )
140
147
}
@@ -143,11 +150,10 @@ export default async function getClassNames(
143
150
try {
144
151
result = await run ( )
145
152
} catch ( _ ) {
146
- watch ( )
147
153
return null
148
154
}
149
155
150
- watch ( result . dependencies )
156
+ watch ( [ result . configPath , ... result . dependencies ] )
151
157
152
158
return result
153
159
}
You can’t perform that action at this time.
0 commit comments