honojs / vite-plugins

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

Add `include` and `middleware` propery #50

Open oscartbeaumont opened 10 months ago

oscartbeaumont commented 10 months ago

include is the opposite of the existing exclude functionality.

middleware can run prior to parsing the request onto Vite and can return Response or undefined. undefined will pass the request onto Vite while a Response will be directly returned to the client.

This could be used for a manual Hono integration which could run any code to decide what to serve.

changeset-bot[bot] commented 10 months ago

⚠️ No Changeset found

Latest commit: f850a06f753ee9ad95c9ca293683621a63e11fe5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

mdluo commented 10 months ago

The include rule will be really useful!

Sometimes I just need Hono to handle a few routes that don't have a common prefix, and leave all the rest to be handled by Vite dev server locally and served as static content on Cloudflare Pages. This is really tricky to achieve with only exclude rules.

@yusukebe looking forward to having this option!

yusukebe commented 10 months ago

Hi @oscartbeaumont !

Sorry for the delay. This is awesome!

I think it can be factored, but I would like you to write tests first. This project has e2e tests, so please add the tests there.

https://github.com/honojs/vite-plugins/tree/main/packages/dev-server/e2e

Thanks!

BierDav commented 5 months ago

Are there any updates for this pr to get merged?