fastify-vite icon indicating copy to clipboard operation
fastify-vite copied to clipboard

Add option to turn off `index.html` read in `onRequest` hook

Open jlenon7 opened this issue 1 year ago • 4 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

Hey people, thank you so much for this package, really helpful!

I'm trying to create an integration using this package + Edge.js (template engine).

I created a project template, but I needed to change some things inside node_modules/@fastify/vite to get it working. I had to comment these lines:

https://github.com/fastify/fastify-vite/blob/169b718d3f306b922c5666f659d0a201dfd8c861/packages/fastify-vite/mode/development.js#L84-L96

[!TIP] Project template: https://github.com/jlenon7/vite-fastify. After installing dependencies, use npm run dev to start it.

Since I'm using Edge.js for the template engine with multiple pages, I don't need the index.html entry point, instead I use app.scss and app.js as entry points as you can see inside my vite.config.js

Is there an easier way to create this integration? I had the idea to expose an option when registering @fastify/vite to turn index.html loading off inside onRequest hook. I would be happy to send a PR if you guys agree with the idea!

Motivation

No response

Example

No response

jlenon7 avatar Jan 01 '25 20:01 jlenon7

Would checking if index.html exists suffice?

galvez avatar Mar 30 '25 16:03 galvez

Also what if you want to have multiple entry points (An MPA)? There could be multiple different index.html involved...

segevfiner avatar Jun 25 '25 09:06 segevfiner

Would checking if index.html exists suffice?

Yes. I will make a PR for that 👍

Also what if you want to have multiple entry points (An MPA)? There could be multiple different index.html involved...

Yes, a different HTML will be returned on each entry point. Since I'm using Edge.js (template engine), I'm able to create only one index.edge and use in other views as a component.

jlenon7 avatar Jun 26 '25 12:06 jlenon7

I am incredibly swamped at work but will circle back on this over the weekend.

galvez avatar Jun 26 '25 15:06 galvez