Skip to content

Commit b3c55f3

Browse files
committed
feat: only initialize vite if available
1 parent 6b8d771 commit b3c55f3

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/App.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* The easiest way to build simple but powerful apps and APIs quickly.
1111
*
1212
* @author Michael Darko <[email protected]>
13-
* @copyright 2019-2024 Michael Darko
13+
* @copyright 2019-2025 Michael Darko
1414
* @link https://leafphp.dev
1515
* @license MIT
1616
* @package Leaf
@@ -203,15 +203,18 @@ public function cors($options = [])
203203
/**
204204
* Tune vite to work without Leaf MVC
205205
*/
206-
public function vite($options = [
207-
'assets' => '',
208-
'build' => '',
209-
'hotFile' => 'hot',
210-
])
211-
{
212-
\Leaf\Vite::config('assets', $options['assets']);
213-
\Leaf\Vite::config('build', $options['build']);
214-
\Leaf\Vite::config('hotFile', $options['hotFile']);
206+
public function vite(
207+
$options = [
208+
'assets' => '',
209+
'build' => '',
210+
'hotFile' => 'hot',
211+
]
212+
) {
213+
if (class_exists('Leaf\Vite')) {
214+
\Leaf\Vite::config('assets', $options['assets']);
215+
\Leaf\Vite::config('build', $options['build']);
216+
\Leaf\Vite::config('hotFile', $options['hotFile']);
217+
}
215218
}
216219

217220
/**

0 commit comments

Comments
 (0)