Skip to content

About

Provides support for Full Bundle Mode in backend integrations

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

vite-plugin-backend-full-bundle

Expose backend-friendly script and style tags for Vite dev and Full Bundle Mode


Why? 🤔

Vite 8 announcement introduced Full Bundle Mode, which is very promising for backend integrations (Rails, Laravel, etc.).

In regular dev mode, backends usually inject source entry tags (/@vite/client + entry module). In Full Bundle Mode, Vite serves bundled HTML output from memory, so those assumptions no longer hold.

This plugin provides a backend-facing endpoint that returns the actual script/style/preload tags Vite resolves in dev, including bundled dev.

Related context: rolldown#9030.

Installation 💿

Install the package as a development dependency:

npm i -D vite-plugin-backend-full-bundle

Usage 🚀

Add it to your plugins in vite.config.ts:

import { defineConfig } from 'vite'
import BackendFullBundle from 'vite-plugin-backend-full-bundle'

export default defineConfig({
  plugins: [BackendFullBundle()],
})

Then request:

GET /@vite-plugin-backend-full-bundle/entry-tags?entry=index.html

Example response:

{
  "entry": "index.html",
  "tags": {
    "scripts": [{ "src": "/@vite/client" }, { "src": "/main.ts" }],
    "styles": [{ "href": "/style.css" }],
    "preloads": []
  }
}

In Full Bundle Mode, tags come from bundled in-memory HTML output.

Configuration ⚙️

BackendFullBundle(options?)

  • endpoint?: string

    • Custom endpoint path.
    • Default: /@vite-plugin-backend-full-bundle/entry-tags
  • defaultEntry?: string

    • Fallback entry when entry query param is missing.
    • Default: index.html

License

This library is available as open source under the terms of the MIT License.

About

Provides support for Full Bundle Mode in backend integrations

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages