bohn-media / contao-vite-bundle
Vite Bundle for Contao 5
Package info
github.com/bohn-media/contao-vite-bundle
Type:contao-bundle
pkg:composer/bohn-media/contao-vite-bundle
Requires
- php: ^8.2
- contao/core-bundle: ^5.0
- contao/manager-plugin: ^2.0
- pentatrion/vite-bundle: ^8.0
- symfony/http-kernel: ^6.4 || ^7.0
Requires (Dev)
README
A small Contao 5 wrapper around pentatrion/vite-bundle. It
registers PentatrionViteBundle in Contao Manager Edition and exposes the
most common rendering helpers as Contao insert tags.
Installation
composer require bohn-media/contao-vite-bundle
The bundle expects Vite to output its build artifacts into public/build/
(the default).
Rendering entry tags
Render the link and script tags for a Vite entry.
Twig
{{ vite_entry_link_tags('app') }}
{{ vite_entry_script_tags('app') }}
Insert tag
{{vite_entry_link_tags::app}}
{{vite_entry_script_tags::app}}
If the entry name is missing or rendering fails (e.g. unknown entry,
broken entrypoints.json), the insert tags render as an empty string and
log an error instead of throwing.
Resolving individual asset URLs
A named asset package vite is registered automatically, so Vite-hashed
assets resolve via Symfony's asset() function or Contao's {{asset::}}
insert tag.
Twig
{{ asset('@/images/favicon.svg', 'vite') }}
Insert tag
{{asset::@/images/favicon.svg::vite}}
License
MIT.