How To Reference Images after running yarn run build:production

I’m pretty new to webpack. I’m having a hard time figuring out how to reference images after running yarn run build:production since that hashes the images in the dist folder.

How do you reference those hashed images in the blade template?

Alright I figured out a way in Sage 9 to reference the hashed build images.

<img src="{{ App\config('assets.uri') }}/{{ App\sage('sage.assets')->manifest['images/example.png'] }}"

Is this the correct way to reference images in Sage 9? I didn’t see this in the documentation.

See https://github.com/roots/docs/blob/sage-9/sage/theme-development-and-building.md#images-in-template-files

1 Like