Skip to content

Create plug-in for Sveltekit root projects #9

@webJose

Description

@webJose

Problem

Sveltekit doesn't support the transformIndexHtml Vite hook. This is where @collagejs/vite-im collects import map information and injects it into the page. Since Sveltekit projects don't run this hook, the plug-in doesn't work with it.

Proposed Solution

Until the day the Vite hook is supported, I see no other way than creating a new plug-in, @collagejs/vite-kit, that:

  • During development (npm run dev), uses a brute-force method to intercept all generated HTML responses to inject the import map
  • During build, provides the transformPageChunk server hook to perform the same injection

This is the only way I see ATM to beat Vite's HMR client script injection (that renders import maps useless).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: MediumMedium priority. Upvote to upgrade; downvote to downgrade.SveltekitRelated to Sveltekit.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions