';
}
function jsPreloadImports(string $entry): string
{
if (isDev($entry)) {
return "";
}
$res = "";
foreach (importsUrls($entry) as $url) {
$res .= '';
}
return $res;
}
function cssTag(string $entry): string
{
// not needed on dev, it's inject by Vite
if (isDev($entry)) {
return "";
}
$tags = "";
foreach (cssUrls($entry) as $url) {
$tags .= '';
}
return $tags;
}
// Helpers to locate files
function getManifest(): array
{
$urlManifest = find_in_path("dist/manifest.json");
$content = file_get_contents($urlManifest);
return json_decode($content, true);
}
function assetUrl(string $entry): string
{
$manifest = getManifest();
return isset($manifest[$entry])
? find_in_path("dist/" . $manifest[$entry]["file"])
: "";
}
function importsUrls(string $entry): array
{
$urls = [];
$manifest = getManifest();
if (!empty($manifest[$entry]["imports"])) {
foreach ($manifest[$entry]["imports"] as $imports) {
$urls[] = find_in_path("dist/" . $manifest[$imports]["file"]);
}
}
return $urls;
}
function cssUrls(string $entry): array
{
$urls = [];
$manifest = getManifest();
if (!empty($manifest[$entry]["css"])) {
foreach ($manifest[$entry]["css"] as $file) {
$urls[] = find_in_path("dist/" . $file);
}
}
return $urls;
}