| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the WindPress package. |
| 5 |
* |
| 6 |
* (c) Joshua Gugun Siagian <suabahasa@gmail.com> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
declare (strict_types=1); |
| 12 |
namespace WindPress\WindPress\Utils; |
| 13 |
|
| 14 |
use WindPressDeps\Nabasa\VitePlus\Assets; |
| 15 |
use WIND_PRESS; |
| 16 |
final class Vite |
| 17 |
{ |
| 18 |
private const SCOPE = 'windpress'; |
| 19 |
private static ?Assets $assets = null; |
| 20 |
private function __construct() |
| 21 |
{ |
| 22 |
} |
| 23 |
public static function assets(): Assets |
| 24 |
{ |
| 25 |
if (self::$assets === null) { |
| 26 |
self::$assets = \WindPressDeps\Nabasa\VitePlus\assets(self::manifest_dir(), self::SCOPE); |
| 27 |
} |
| 28 |
return self::$assets; |
| 29 |
} |
| 30 |
public static function manifest(): object |
| 31 |
{ |
| 32 |
return \WindPressDeps\Nabasa\VitePlus\get_manifest(self::manifest_dir(), self::SCOPE); |
| 33 |
} |
| 34 |
public static function manifest_dir(): string |
| 35 |
{ |
| 36 |
return dirname(WIND_PRESS::FILE) . '/build'; |
| 37 |
} |
| 38 |
public static function base_url(string $asset = ''): string |
| 39 |
{ |
| 40 |
$url = self::assets()->url($asset); |
| 41 |
if ($asset === '') { |
| 42 |
return trailingslashit($url); |
| 43 |
} |
| 44 |
return $url; |
| 45 |
} |
| 46 |
} |
| 47 |
|