Skip to content

Commit

Permalink
Update vite-manifest.php
Browse files Browse the repository at this point in the history
allow custom path
  • Loading branch information
iamntz authored Dec 10, 2023
1 parent b1bb86e commit ad93615
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/functions/vite-manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,22 @@ function set_script_type_attribute(string $target_handle, string $tag, string $h
*/
function generate_development_asset_src(object $manifest, string $entry): string
{
$origin = get_site_url() . ":{$manifest->data->port}";
$origin = apply_filters('iamntz/wp-vite-manifest/development_assets_origin', get_home_url() . ":{$manifest->data->port}", $manifest, $entry);

$path = apply_filters(
'iamntz/wp-vite-manifest/development_asset_path',
trim(preg_replace('/[\/]{2,}/', '/', "{$manifest->data->base}/{$entry}"), '/'),
$manifest, $entry
);

return sprintf(
'%s/%s',
untrailingslashit($origin),
trim(preg_replace('/[\/]{2,}/', '/', "{$manifest->data->base}/{$entry}"), '/')
$path
);
}


/**
* Register vite client script
*
Expand Down

0 comments on commit ad93615

Please sign in to comment.