@php
use Illuminate\Support\Facades\Vite;
$gcUseViteDev = app()->environment('local') && is_file(public_path('gc/hot'));
$cssPath = public_path('css/gc-app.css');
$jsPath = public_path('js/gc-app.js');
$cssUrl = null;
$jsUrl = null;
if (! $gcUseViteDev) {
if (is_file($cssPath)) {
$cssUrl = asset('css/gc-app.css').'?v='.filemtime($cssPath);
} else {
$manifestPath = public_path('gc/build/manifest.json');
$cssEntries = [
'Modules/GletraChatBox/resources/css/app.css',
'resources/css/app.css',
];
if (is_file($manifestPath)) {
$manifest = json_decode(file_get_contents($manifestPath), true) ?: [];
foreach ($cssEntries as $entry) {
if (! empty($manifest[$entry]['file']) && is_file(public_path('gc/build/'.$manifest[$entry]['file']))) {
$cssUrl = asset('gc/build/'.$manifest[$entry]['file']);
break;
}
}
}
if (! $cssUrl) {
$builtCss = glob(public_path('gc/build/assets/app-*.css')) ?: [];
if ($builtCss !== []) {
$cssUrl = asset('gc/build/assets/'.basename(end($builtCss)));
}
}
}
if (is_file($jsPath)) {
$jsUrl = asset('js/gc-app.js').'?v='.filemtime($jsPath);
} else {
$manifestPath = $manifestPath ?? public_path('gc/build/manifest.json');
$jsEntries = [
'Modules/GletraChatBox/resources/js/app.js',
'resources/js/app.js',
];
if (is_file($manifestPath)) {
$manifest = json_decode(file_get_contents($manifestPath), true) ?: [];
foreach ($jsEntries as $entry) {
if (! empty($manifest[$entry]['file']) && is_file(public_path('gc/build/'.$manifest[$entry]['file']))) {
$jsUrl = asset('gc/build/'.$manifest[$entry]['file']);
break;
}
}
}
if (! $jsUrl) {
$builtJs = glob(public_path('gc/build/assets/app-*.js')) ?: [];
if ($builtJs !== []) {
$jsUrl = asset('gc/build/assets/'.basename(end($builtJs)));
}
}
}
}
@endphp
@if ($gcUseViteDev)
{{ Vite::useHotFile(public_path('gc/hot'))
->useBuildDirectory('gc/build')
->withEntryPoints([
'Modules/GletraChatBox/resources/css/app.css',
'Modules/GletraChatBox/resources/js/app.js',
]) }}
@else
@if ($cssUrl)
@elseif (app()->environment('local'))
{{ Vite::useBuildDirectory('gc/build')
->withEntryPoints([
'Modules/GletraChatBox/resources/css/app.css',
'Modules/GletraChatBox/resources/js/app.js',
]) }}
@endif
@if ($jsUrl)
@endif
@endif