From 091978548577542ecb1a8f1ddead315aba1242b5 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Sat, 4 May 2024 22:04:46 +0900 Subject: [PATCH] `readdir` in the `writeBundle` --- .../cloudflare-pages/src/cloudflare-pages.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/cloudflare-pages/src/cloudflare-pages.ts b/packages/cloudflare-pages/src/cloudflare-pages.ts index 3b94528..7af2cf6 100644 --- a/packages/cloudflare-pages/src/cloudflare-pages.ts +++ b/packages/cloudflare-pages/src/cloudflare-pages.ts @@ -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) { @@ -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 }