I need to get a URL for an image stored in my theme (app/design/frontend/MyVendor/MyTheme/web/images/image.png
) from a javascript file (payment.js
).
In PHP I can do it like this:
<?php echo $block->getViewFileUrl('images/image.png') ?>
How can I do this in JavaScript?
In JavaScript it's available with require.toUrl('images/image.png')
.