Skip to content

Commit 43b089f

Browse files
committed
Merge branch 'master' into develop
2 parents cf04ecd + 3d3195a commit 43b089f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

index.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
function mix($path)
1717
{
18+
$kirby = kirby();
19+
1820
// Handle arrays
1921
if (is_array($path)) {
2022
$assets = [];
@@ -72,7 +74,7 @@ function mix($path)
7274
}
7375
}
7476

75-
$path = '/'.$type.'/templates/'.kirby()->site()->page()->intendedTemplate().'.'.$type;
77+
$path = '/'.$type.'/templates/'.$kirby->site()->page()->intendedTemplate().'.'.$type;
7678
}
7779

7880
// Check if the manifest contains the given $path
@@ -84,8 +86,18 @@ function mix($path)
8486
}
8587
}
8688

89+
// Check if Mix is in hmr mode
90+
$mixHmrFile = $kirby->root('index') . $assetsDirectory . '/hot';
91+
8792
// Get the actual file path for the given $path
88-
$mixFilePath = $assetsDirectory . $manifest[$path];
93+
if (F::exists($mixHmrFile)) {
94+
// Remove white space from string and remove ending forward slash
95+
$hmrHost = preg_replace('/\s+/', '', F::read($mixHmrFile));
96+
$hmrHost = substr($hmrHost, 0, -1);
97+
$mixFilePath = $hmrHost . $manifest[$path];
98+
} else {
99+
$mixFilePath = $assetsDirectory . $manifest[$path];
100+
}
89101

90102
// Use the appropriate Kirby helper method to get the correct HTML tag
91103
$pathExtension = F::extension($mixFilePath);

0 commit comments

Comments
 (0)