A Vite plugin that enables Hot Module Replacement (HMR) for Drupal Twig templates and Single-Directory Components. Current stable version is 1.0.1, released on a low cadence. It uses Vite's HMR API and Drupal's Twig debug mode to fetch updated HTML and perform DOM replacements when a .twig file changes. Limited to theme suggestions and does not support TypeScript or automated testing. Differentiates from other Drupal build tools by providing instant template reloads without full page refresh, but requires a compatible Vite-Drupal setup (e.g., via the Vite module) and a virtual module script injected into the backend.
npm install vite-plugin-drupal-twig-hmrVerified import paths — ran on the pinned version, not inferred.
Basic setup of the plugin in a Vite config file, showing import, server port, and plugin usage with optional templateBase option.
No action needed; this is by design. Ensure you only rely on the plugin in development.
Restructure templates to be theme suggestions where possible. For included templates, a full page reload may be needed.
Enable debug mode in Drupal's services.yml or settings.local.php.
Add <script src='http://localhost:5173/@vite-plugin-drupal-template-hmr' type='module'></script> to your HTML or page template.
Run `npm install vite-plugin-drupal-twig-hmr --save-dev`
Use `import viteDrupalTwigHMR from 'vite-plugin-drupal-twig-hmr'` in an ESM context (type: module in package.json or .mjs extension).
Ensure Vite dev server is running on the expected port (e.g., 5173) and the script src matches (e.g., http://localhost:5173/@vite-plugin-drupal-template-hmr).
No dependency data recorded yet.