Skip to content

Commit c276823

Browse files
authored
rename
1 parent 19e5306 commit c276823

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

src/functions.php

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
use Illuminate\Support\HtmlString;
4+
use Illuminate\Support\Str;
5+
6+
/**
7+
* Override from laravel vendor to solve the issue about frontend rebuild required for new js files
8+
* while phpunit does not require js
9+
*
10+
*
11+
* Get the path to a versioned Mix file.
12+
*
13+
* @param string $path
14+
* @param string $manifestDirectory
15+
*
16+
* @return \Illuminate\Support\HtmlString
17+
*
18+
* @throws \Exception
19+
*/
20+
function mix($path, $manifestDirectory = '')
21+
{
22+
dd('here');
23+
static $manifests = [];
24+
25+
if (! Str::startsWith($path, '/')) {
26+
$path = "/{$path}";
27+
}
28+
29+
if ($manifestDirectory && ! Str::startsWith($manifestDirectory, '/')) {
30+
$manifestDirectory = "/{$manifestDirectory}";
31+
}
32+
33+
if (file_exists(public_path($manifestDirectory.'/hot'))) {
34+
return new HtmlString("//localhost:8080{$path}");
35+
}
36+
37+
$manifestPath = public_path($manifestDirectory.'/mix-manifest.json');
38+
39+
if (! isset($manifests[$manifestPath])) {
40+
if (! file_exists($manifestPath)) {
41+
throw new Exception('The Mix manifest does not exist.');
42+
}
43+
44+
$manifests[$manifestPath] = json_decode(file_get_contents($manifestPath), true);
45+
}
46+
47+
$manifest = $manifests[$manifestPath];
48+
49+
if (! isset($manifest[$path])) {
50+
report(new Exception("Unable to locate Mix file: {$path}."));
51+
52+
if (! app('config')->get('app.debug')) {
53+
return $path;
54+
}
55+
}
56+
57+
// addon for fix
58+
if(preg_match('|phpunit$|', $_SERVER['SCRIPT_NAME']) && ! array_key_exists($path, $manifest)) {
59+
$manifest[$path] = $path;
60+
}
61+
62+
return new HtmlString($manifestDirectory.$manifest[$path]);
63+
}

0 commit comments

Comments
 (0)