This commit is contained in:
Christophe 2024-07-17 15:45:52 +02:00
parent 3cf610a22a
commit b6f86ad302

View file

@ -70,7 +70,11 @@ function jsTag(string $entry): string {
return ""; return "";
} }
return '<script type="module" crossorigin src="' . $url . '"></script>'; if (isDev($entry)) {
return '<script type="module" src="' . VITE_HOST . '/@vite/client"></script>' . "\n"
. '<script type="module" src="' . $url . '"></script>';
}
return '<script type="module" src="' . $url . '"></script>';
} }
function jsPreloadImports(string $entry): string { function jsPreloadImports(string $entry): string {
@ -101,10 +105,24 @@ function cssTag(string $entry): string {
// Helpers to locate files // Helpers to locate files
function getManifest(): array { function getManifest(): array {
$urlManifest = find_in_path("dist/manifest.json"); static $urlManifest;
if ($urlManifest === null) {
// vite V5
if (find_in_path("dist/.vite/manifest.json")) {
$urlManifest = find_in_path("dist/.vite/manifest.json");
// vite V4
} else if (find_in_path("dist/manifest.json")) {
$urlManifest = find_in_path("dist/manifest.json");
}
}
if ($urlManifest) {
$content = file_get_contents($urlManifest); $content = file_get_contents($urlManifest);
return json_decode($content, true); return json_decode($content, true);
} else {
die('pas de fichier manifest.json');
}
} }
function assetUrl(string $entry): string { function assetUrl(string $entry): string {