Skip to content

Commit c1e6267

Browse files
haoqunjiangfreddy38510
authored andcommitted
fix: properly close the watcher after tests
1 parent 46b87ac commit c1e6267

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: src/pluginWebpack4.ts

+9
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ class VueLoaderPlugin {
173173
watcher.close()
174174
}
175175
})
176+
177+
// In some cases, e.g. in this project's tests,
178+
// even though needsHMR() returns true, webpack is not watching, thus no watchClose hook is called.
179+
// So we need to close the watcher when webpack is done.
180+
compiler.hooks.done.tap(id, () => {
181+
if (watcher) {
182+
watcher.close()
183+
}
184+
})
176185
}
177186
}
178187
}

0 commit comments

Comments
 (0)