Vite plugin that resolves Edge Side Includes (ESI) directives during the Vite dev server and build process using the nodesi library. Current stable version is 1.3.1 (April 2024). The plugin uses HTML comments as placeholders to inject ESI tags or resolved HTML fragments. Key differentiators: supports both resolving ESI into final HTML or preserving raw ESI tags for server-side processing, customizable nodesi options, and header forwarding. It is designed for Vite projects that need ESI integration, particularly in micro-frontend architectures or edge delivery setups.
npm install vite-plugin-esiVerified import paths — ran on the pinned version, not inferred.
Basic setup: install and configure vite-plugin-esi with two ESI fragments for the head section.
Ensure comments match: <!--vite-plugin-esi name="yourKey" -->
Upgrade to >=1.2.0 or use ESM-compatible setup.
Use esiOptions object for nodesi options: esiOptions: { baseDir: '...' }Use only in main HTML entry. For other files, consider alternative ESI implementations.
Define fragments in the desired order in the array.
npm i -D vite-plugin-esi and use import viteEsi from 'vite-plugin-esi'
Use import viteEsi from 'vite-plugin-esi' (default export) instead of destructured import.
Ensure esi option includes a key matching the comment's name attribute.
Check that the ESI fragment URLs are accessible during build/server.