Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions packages/vite/src/node/server/warmup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs/promises'
import path from 'node:path'
import colors from 'picocolors'
import { glob } from 'tinyglobby'
import { glob, isDynamicPattern } from 'tinyglobby'
import { FS_PREFIX } from '../constants'
import { normalizePath } from '../utils'
import type { ViteDevServer } from '../index'
Expand Down Expand Up @@ -72,10 +72,29 @@ function fileToUrl(file: string, root: string) {

async function mapFiles(files: string[], root: string) {
if (!files.length) return []
return await glob(files, {
absolute: true,
cwd: root,
expandDirectories: false,
ignore: ['**/.git/**', '**/node_modules/**'],
})

const result: string[] = []
const globs: string[] = []
for (const file of files) {
if (isDynamicPattern(file)) {
globs.push(file)
} else {
if (path.isAbsolute(file)) {
result.push(file)
} else {
result.push(path.resolve(root, file))
}
}
}
if (globs.length) {
result.push(
...(await glob(globs, {
absolute: true,
cwd: root,
expandDirectories: false,
ignore: ['**/.git/**', '**/node_modules/**'],
})),
)
}
return result
}
Loading