Skip to content

Commit

Permalink
fix: properly close the watcher after tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed May 28, 2023
1 parent a81dc0f commit 40b93b9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/pluginWebpack4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ class VueLoaderPlugin {
watcher.close()
}
})

// In some cases, e.g. in this project's tests,
// even though needsHMR() returns true, webpack is not watching, thus no watchClose hook is called.
// So we need to close the watcher when webpack is done.
compiler.hooks.done.tap(id, () => {
if (watcher) {
watcher.close()
}
})
}
}
}
Expand Down

0 comments on commit 40b93b9

Please sign in to comment.