Skip to content

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

Open
@jlenon7

Description

@jlenon7

Prerequisites

  • I have written a descriptive issue title
  • 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:

const indexHtmlPath = join(config.vite.root, 'index.html')
const indexHtml = await read(indexHtmlPath, 'utf8')
const transformedHtml = await this.devServer.transformIndexHtml(
req.url,
indexHtml,
)
// Set reply.html() function with latest version of index.html
reply.html = await config.createHtmlFunction(
transformedHtml,
this.scope,
config,
)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions