UNPKG

vike

Version:

(Replaces Next.js/Nuxt) 🔨 Composable framework to build advanced applications with flexibility and stability.

24 lines (23 loc) • 1.3 kB
export { findPageFiles }; import { glob } from 'tinyglobby'; import { scriptFileExtensionPattern } from '../../../utils/isScriptFile.js'; import { toPosixPath } from '../../../utils/path.js'; import { assertWarning } from '../../../utils/assert.js'; import pc from '@brillout/picocolors'; import { getOutDirs } from './getOutDirs.js'; import '../assertEnvVite.js'; async function findPageFiles(config, fileTypes, isDev) { const cwd = config.root; const { outDirRoot } = getOutDirs(config, undefined); 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; }