Skip to content

Commit 902d273

Browse files
authored
fix: resolve path matching in hmr by using relative paths (#564)
1 parent 4241a5a commit 902d273

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/core/unplugin.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Options } from '../types'
2+
import path from 'node:path'
23
import { slash } from '@antfu/utils'
34
import { isPackageExists } from 'local-pkg'
45
import pm from 'picomatch'
@@ -41,7 +42,8 @@ export default createUnplugin<Options>((options) => {
4142
}
4243
},
4344
async handleHotUpdate({ file }) {
44-
if (ctx.dirs?.some(dir => pm.isMatch(slash(file), slash(typeof dir === 'string' ? dir : dir.glob))))
45+
const relativeFile = path.relative(ctx.root, slash(file))
46+
if (ctx.dirs?.some(dir => pm.isMatch(slash(relativeFile), slash(typeof dir === 'string' ? dir : dir.glob))))
4547
await ctx.scanDirs()
4648
},
4749
async configResolved(config) {

0 commit comments

Comments
 (0)