-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmix.php
39 lines (27 loc) · 1017 Bytes
/
mix.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
function mix($path) {
$manifests = [];
$publicPath = __DIR__ . '/public';
if (substr($path, 0, 1) !== '/') {
$path = "/{$path}";
}
// if (file_exists(public_path('/hot'))) {
// $url = rtrim(file_get_contents(public_path('/hot')));
// if (Str::startsWith($url, ['http://', 'https://'])) {
// return new HtmlString(Str::after($url, ':').$path);
// }
// return new HtmlString("//localhost:8080{$path}");
// }
$manifestPath = $publicPath . '/mix-manifest.json';
if (! isset($manifests[$manifestPath])) {
if (! file_exists($manifestPath)) {
throw new Exception('The Mix manifest does not exist.');
}
$manifests[$manifestPath] = json_decode(file_get_contents($manifestPath), true);
}
$manifest = $manifests[$manifestPath];
if (! isset($manifest[$path])) {
throw new Exception("Unable to locate Mix file: {$path}.");
}
return '/client' . $manifest[$path];
}