diff --git a/inc/vite.php b/inc/vite.php index 0dc1daa..121487c 100644 --- a/inc/vite.php +++ b/inc/vite.php @@ -70,7 +70,11 @@ function jsTag(string $entry): string { return ""; } - return ''; + if (isDev($entry)) { + return '' . "\n" + . ''; + } + return ''; } function jsPreloadImports(string $entry): string { @@ -101,10 +105,24 @@ function cssTag(string $entry): string { // Helpers to locate files function getManifest(): array { - $urlManifest = find_in_path("dist/manifest.json"); + static $urlManifest; - $content = file_get_contents($urlManifest); - return json_decode($content, true); + 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); + return json_decode($content, true); + } else { + die('pas de fichier manifest.json'); + } } function assetUrl(string $entry): string {