-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite_helper.php
More file actions
31 lines (26 loc) · 867 Bytes
/
vite_helper.php
File metadata and controls
31 lines (26 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
if (!function_exists('vite')) {
function vite()
{
$hotFile = ROOTPATH . '.vite/hot';
$isDev = is_file($hotFile);
$devUrl = 'http://localhost:5173';
if ($isDev) {
return "<script type='module' src='{$devUrl}/@vite/client'></script>"
. "<script type='module' src='{$devUrl}/resources/js/app.js'></script>";
}
$assets = @include FCPATH . 'vite.php';
if (!is_array($assets)) {
return '';
}
$tags = '';
foreach ($assets as $asset) {
if (str_ends_with($asset, '.js')) {
$tags .= "<script type='module' src='{$asset}'></script>";
} elseif (str_ends_with($asset, '.css')) {
$tags .= "<link rel='stylesheet' href='{$asset}'>";
}
}
return $tags;
}
}