Created
January 19, 2022 07:56
-
-
Save bjornbjorn/2df4f9ceef6de3a6a7547809c02008c6 to your computer and use it in GitHub Desktop.
Getting innocenzi/laravel-vite to work with TwigBrigde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<-- outpiut vite tags --> | |
{{ vite()|raw }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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