Skip to content

Instantly share code, notes, and snippets.

@bjornbjorn
Created January 19, 2022 07:56
Show Gist options
  • Save bjornbjorn/2df4f9ceef6de3a6a7547809c02008c6 to your computer and use it in GitHub Desktop.
Save bjornbjorn/2df4f9ceef6de3a6a7547809c02008c6 to your computer and use it in GitHub Desktop.
Getting innocenzi/laravel-vite to work with TwigBrigde
<-- outpiut vite tags -->
{{ vite()|raw }}
// In TwigBridge.php (or a better location if you don't want to be too hacky)
use Innocenzi\Vite\Vite;
use Twig\TwigFunction;
lass ViteExtension extends Twig\Extension\AbstractExtension {
public function getFunctions()
{
return [
new TwigFunction('vite', [$this, 'vite']),
];
}
public function vite() {
return vite_tags();
}
}
...
/*
|
| Enabled extensions.
|
| `Twig\Extension\DebugExtension` is enabled automatically if twig.debug is TRUE.
|
*/
'enabled' => [
'ViteExtension', // add the extension here
'TwigBridge\Extension\Loader\Facades',
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment