Skip to content

Commit 4d8a564

Browse files
fix: fix paths in Windows (#20)
1 parent 1eb59da commit 4d8a564

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/context.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { relative } from 'path'
1+
import { join, relative, resolve } from 'path'
22
import Debug from 'debug'
33
import chokidar from 'chokidar'
44
import { ResolvedConfig, UpdatePayload, ViteDevServer } from 'vite'
@@ -40,17 +40,24 @@ export class Context {
4040
: `${i}/*.${extsGlob}`,
4141
)
4242

43+
const watchDirs = toArray(dirs).map(i => resolve(viteConfig.root, i))
44+
const watchGlobs = toArray(watchDirs).map(i =>
45+
deep
46+
? join(i, `/**/*.${extsGlob}`)
47+
: join(i, `/*.${extsGlob}`),
48+
)
49+
4350
if (viteConfig.command === 'serve') {
4451
// TODO: use vite's watcher instead
45-
chokidar.watch(dirs, { ignoreInitial: true })
52+
chokidar.watch(watchDirs, { ignoreInitial: true })
4653
.on('unlink', (path) => {
47-
if (matchGlobs(path, this.globs)) {
54+
if (matchGlobs(path, watchGlobs)) {
4855
this.removeComponents(path)
4956
this.onUpdate(path)
5057
}
5158
})
5259
.on('add', (path) => {
53-
if (matchGlobs(path, this.globs)) {
60+
if (matchGlobs(path, watchGlobs)) {
5461
this.addComponents(path)
5562
this.onUpdate(path)
5663
}

src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export function resolveOptions(options: Options, viteConfig: ResolvedConfig): Re
7676
resolvedOptions.libraries = toArray(resolvedOptions.libraries).map(i => typeof i === 'string' ? { name: i } : i)
7777
resolvedOptions.customComponentResolvers = toArray(resolvedOptions.customComponentResolvers)
7878
resolvedOptions.customComponentResolvers.push(...resolvedOptions.libraries.map(lib => LibraryResolver(lib)))
79-
resolvedOptions.dirs = toArray(resolvedOptions.dirs).map(i => resolve(viteConfig.root, i))
8079

8180
return resolvedOptions
8281
}

0 commit comments

Comments
 (0)