Integrates Vite with Craft CMS without requiring a Craft plugin. Current stable version is 4.0.0, compatible with Vite 6 or 7 and Node 18+. The plugin parses Vite's HTML output and generates Twig partials for asset injection. Key differentiators: no Craft plugin needed, supports multiple entry points, auto-generates Twig macros for static assets, and respects Vite's server.origin. Release cadence: major versions track Vite major releases, with minor/patch updates for dependency bumps.
npm install vite-plugin-craftcmsVerified import paths — ran on the pinned version, not inferred.
Minimal Vite config using vite-plugin-craftcms with entry.html, Twig partial output, and dev server on port 3000.
Upgrade Node to >=18 and Vite to >=6.0.0.
Update outputFile to include '[name]' for multiple entry points.
Use a minimal HTML fragment with relative asset paths in './src'.
Place static assets in the directory specified by publicDir (e.g., './web/dist').
Run 'npm i -D vite-plugin-craftcms' and use 'import { vitePluginCraftCms } from 'vite-plugin-craftcms''.Change 'import vitePluginCraftCms from ...' to 'import { vitePluginCraftCms } from ...'.Upgrade Node to version 18 or higher.
Set server.origin in Vite config or ensure dev server uses HTTPS if production does.