Closed brookqin closed 1 year ago
https://github.com/emosheeep/vite-plugin-virtual-mpa/blob/d70771090351bfa2a1f40abb39e4f6c9b8e9363b/workspaces/plugin/src/plugin.ts#L307-L329
function scanPages(scanOptions?: ScanOptions, defaultTemplate: string) { const { filename, entryFile, scanDirs } = scanOptions || {} as ScanOptions; const pages: Page[] = []; for (const entryDir of [scanDirs].flat().filter(Boolean)) { for (const name of fs.readdirSync(entryDir)) { const dir = path.join(entryDir, name); // dir path if (!fs.statSync(dir).isDirectory()) continue; const templateFile = path.join(dir, defaultTemplate); pages.push({ name, filename: typeof filename === 'function' ? filename(name) as Page['filename'] : undefined, entry: entryFile ? path.join('/', dir, entryFile) as Page['entry'] : undefined, template: fs.existsSync(templateFile) ? templateFile : undefined }); } } return pages; }
这个可以考虑
https://github.com/emosheeep/vite-plugin-virtual-mpa/blob/d70771090351bfa2a1f40abb39e4f6c9b8e9363b/workspaces/plugin/src/plugin.ts#L307-L329