I have a Vue app where I want to access some image files in an included JS file for various purposes, e.g. one of which is adding images to a canvas element.
This would normally be easy using something like the following:
function getImage() {
  let img = new Image();
  img.src = '/assets/images/bg.jpg';
  img.onload = function () {
    //
  };
}
I can technically access images in my public folder this way, but what if I want to access compiled image assets from my src folder rather than public folder?
In CSS I can simply use an @ symbol in the path like @/assets/images/bg.jpg (as this is configured as an alias in the vue config) so I tried...
img.src = '@/assets/images/bg.jpg';
...but this doesn't work.
Is there a way to achieve this, or is what I'm trying not possible? Perhaps assets referenced purely in JS aren't included in the build process? Thanks
srcdirectory, as that gets 'compiled' into your bundle. Could you not put the assets withinpublic?