UNPKG

vike

Version:

The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.

21 lines (20 loc) 1.15 kB
export { findPageFiles }; import { glob } from 'tinyglobby'; import { assertWarning, toPosixPath, scriptFileExtensionPattern } from '../utils.js'; import pc from '@brillout/picocolors'; import { getOutDirs } from './getOutDirs.js'; async function findPageFiles(config, fileTypes, isDev) { const cwd = config.root; const { outDirRoot } = getOutDirs(config); const timeBase = new Date().getTime(); let pageFiles = await glob(fileTypes.map((fileType) => `**/*${fileType}.${scriptFileExtensionPattern}`), { ignore: ['**/node_modules/**', `${outDirRoot}/**`], cwd, dot: false, expandDirectories: false }); pageFiles = pageFiles.map((p) => '/' + toPosixPath(p)); const time = new Date().getTime() - timeBase; if (isDev) { // We only warn in dev, because while building it's expected to take a long time as tinyglobby is competing for resources with other tasks assertWarning(time < 1.5 * 1000, `Finding your page files ${pc.cyan('**/*.page.*')} took an unexpected long time (${time}ms). Reach out to the vike maintainer.`, { onlyOnce: 'slow-page-files-search', }); } return pageFiles; }