How to refer to assets in Sage 11

In acorn 4 I would refer to assets like a favicon in the example below:

<link rel="icon" type="image/png" sizes="32x32"
  href="<?php echo \Roots\asset('images/favicons/leaf-circuit-logo-32.png') ?>" />

I get an error doing this in acorn 5:

“The asset manifest [/workspaces/REDACTED/wordpress/web/app/themes/REDACTED/public/build/manifest.json] cannot be found.”

I followed the upgrade guide to acorn 5, but it seems I’m just missing something about how we’re supposed to refer to assets in this version. Thank you for any insight you can provide.

Try {{ asset('resources/images/favicons/leaf-circuit-logo-32.png') }} – mainly prefix the path with resources/ and drop the Roots\ namespace.

You can also use Vite::asset() like shown in Asset Bundling (Vite) - Laravel 12.x - The PHP Framework For Web Artisans

Thanks for the reply. I should mention I’m using this in PHP hooks, not a blade file. I tried dropping \Roots but I get the same error.

What would be your recommendation for referring to static assets like this via PHP outside of blade components (wordpress hooks etc.)?

Nevermind. I just used Vite::asset everywhere and things worked great. Maybe the existing way of using the Roots helper doesn’t work in dev anymore, only after a full build?

See examples from the Sage docs: Compiling Assets | Sage Docs | Roots

Thanks @ben I often forget which topics are in acorn and which in sage!

Good document.