A Vite plugin that compiles Twig templates to HTML with Drupal-specific features including Twig namespaces, includes, extends, and Drupal filter/function support. Current stable version 1.6.2, actively maintained, with monthly releases. Integrates with Storybook for component development. Supports Vite 4–7. Key differentiator: Drupal-aware Twig rendering without a Drupal backend, enabling frontend prototyping.
npm install vite-plugin-twig-drupalVerified import paths — ran on the pinned version, not inferred.
Configures Vite to compile Twig templates with Drupal namespaces, enabling use of @components/ and @layouts/ prefixes in templates.
Use ES module import syntax with 'import'
Enable source maps in Vite config: 'build.sourcemap: true'
Register custom filters via the 'drupalFilter' export or configure them in plugin options
Use 'twigOptions' instead of 'twig' in plugin config
Run 'npm install vite-plugin-twig-drupal --save-dev' and ensure import path is correct
Use 'import twigDrupal from 'vite-plugin-twig-drupal''
Add 'namespaces: { components: 'path/to/components' }' in vite.config.jsNo dependency data recorded yet.