vike
Version:
The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.
26 lines (25 loc) • 1.49 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findPageFiles = findPageFiles;
const tinyglobby_1 = require("tinyglobby");
const utils_js_1 = require("../utils.js");
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
const getOutDirs_js_1 = require("./getOutDirs.js");
async function findPageFiles(config, fileTypes, isDev) {
const cwd = config.root;
const { outDirRoot } = (0, getOutDirs_js_1.getOutDirs)(config);
const timeBase = new Date().getTime();
let pageFiles = await (0, tinyglobby_1.glob)(fileTypes.map((fileType) => `**/*${fileType}.${utils_js_1.scriptFileExtensionPattern}`), { ignore: ['**/node_modules/**', `${outDirRoot}/**`], cwd, dot: false, expandDirectories: false });
pageFiles = pageFiles.map((p) => '/' + (0, utils_js_1.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
(0, utils_js_1.assertWarning)(time < 1.5 * 1000, `Finding your page files ${picocolors_1.default.cyan('**/*.page.*')} took an unexpected long time (${time}ms). Reach out to the vike maintainer.`, {
onlyOnce: 'slow-page-files-search',
});
}
return pageFiles;
}