Skip to content

Commit

Permalink
readdir in the writeBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe committed May 4, 2024
1 parent 7aaf33f commit 0919785
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/cloudflare-pages/src/cloudflare-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@ export const cloudflarePagesPlugin = (options?: CloudflarePagesOptions): Plugin
name: '@hono/vite-cloudflare-pages',
configResolved: async (resolvedConfig) => {
config = resolvedConfig
const paths = await readdir(config.build.outDir, {
withFileTypes: true,
})
paths.forEach((p) => {
if (p.isDirectory()) {
staticPaths.push(`/${p.name}/*`)
} else {
staticPaths.push(`/${p.name}`)
}
})
staticRoutes = {
version: 1,
include: ['/*'],
exclude: staticPaths,
}
},
resolveId(id) {
if (id === virtualEntryId) {
Expand All @@ -82,6 +67,21 @@ export const cloudflarePagesPlugin = (options?: CloudflarePagesOptions): Plugin
}
},
writeBundle: async () => {
const paths = await readdir(config.build.outDir, {
withFileTypes: true,
})
paths.forEach((p) => {
if (p.isDirectory()) {
staticPaths.push(`/${p.name}/*`)
} else {
staticPaths.push(`/${p.name}`)
}
})
staticRoutes = {
version: 1,
include: ['/*'],
exclude: staticPaths,
}
if (!options?.routesJson === false) {
return
}
Expand Down

0 comments on commit 0919785

Please sign in to comment.