Build
This commit is contained in:
parent
3cf610a22a
commit
b6f86ad302
1 changed files with 22 additions and 4 deletions
26
inc/vite.php
26
inc/vite.php
|
@ -70,7 +70,11 @@ function jsTag(string $entry): string {
|
|||
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 {
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue