honojs / vite-plugins

Vite Plugins for Hono
https://hono.dev
134 stars 35 forks source link

feat(cloudflare-pages): generate `_routes.json` #121

Closed yusukebe closed 6 months ago

yusukebe commented 7 months ago

Fixes #110, #116

With this PR, the Vite plugin detects static files in the public directory and adds paths for serveStatic() in worker.js. And, this will emit _routes.json as a default.

The function that detects static files automatically is heavily inspired by @yudai-nkt 's https://github.com/yudai-nkt/awesome-hono/blob/main/vite-plugins/auto-exclude-static-routes.ts. I'll make @yudai-nkt a co-author.

changeset-bot[bot] commented 7 months ago

🦋 Changeset detected

Latest commit: 84b90c498402aaf233526b12e3f2305d2d2ee95e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | --------------------------- | ----- | | @hono/vite-cloudflare-pages | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

yusukebe commented 7 months ago

Hey @yudai-nkt, @nakasyou, @ryuapp!

I've created this PR to resolve both #110 and #116. With this PR, static file paths will automatically be added to worker.js and _routes.json without explicitly specifying paths.

I think this is great. Can you review it?

yusukebe commented 6 months ago

@yudai-nkt @ryuapp

Sorry for being super late. I've updated it. Could you review this?

yusukebe commented 6 months ago

@ryuapp

Thank you! I'll merge this now. Let's go with it!