Is there an easy way to get the relative path of an asset? How can I access the relative path of the /dist
folder? App\\asset_path()
returns the full uri. I have a case where I’m using file_get_contents
to display inline SVGs and i need to provide the relative path, in my case '~/sitename/web/app/themes/ttg-theme/dist/images/svg/file.svg'
.
Edit: Especially considering get_template_directory()
now, returns the ‘resources’ folder, I can’t find an easy way to get the ‘dist’ folder.
Re-edit: This is my current code which requires the hardcoded theme path:
/**
* Create @svg() Blade directive
*/
sage('blade')->compiler()->directive('svg', function ($svg, $size = 'inherit') {
return "<?= file_get_contents(get_theme_root() . '/theme-name/dist/images/svg/' . $svg . '.svg'); ?>";
});