vite-plugin-react-pages
Version:
<p> <a href="https://www.npmjs.com/package/vite-plugin-react-pages" target="_blank" rel="noopener"><img src="https://img.shields.io/npm/v/vite-plugin-react-pages.svg" alt="npm package" /></a> </p>
14 lines (12 loc) • 424 B
text/typescript
import fs from 'fs-extra'
import * as path from 'path'
import slash from 'slash'
export async function resolveTheme(pagesDirPath: string) {
for (let filename of ['_theme.js', '_theme.ts', '_theme.jsx', '_theme.tsx']) {
filename = path.join(pagesDirPath, filename)
if (await fs.pathExists(filename)) {
return slash(filename)
}
}
throw new Error("can't find theme inside pagesDir: " + pagesDirPath)
}