Dynamic path to assets in development and production environment


i’m wondering how i’m suppose to handle assets. For instance if i have a logo that i have under /assets/images/my-logo.svg

i would try to get it with this

<?php echo get_bloginfo('template_directory'); ?>/assets/images/my-logo.svg); ?>

But if i compile it with the --production flag the path should be

<?php echo get_bloginfo('template_directory'); ?>/dist/images/my-logo.svg); ?>

How can i keep this dynamic?

Never reference assets in the assets directory, always reference assets in the dist/ directory.

Correct way to do it:

<?= get_template_directory_uri() . '/dist/images/logo.svg'; ?>