Reputation: 5996
I have a function in an Astro file that generates an image, when it does not exist.
Then as a dynamic import I glob over the image dir and return the image.
const mapImg = ${currentDir}/../assets/${saveTo}/${imageFile};
...
await map.image.save(mapImg, { compressionLevel: 9 });
const images = import.meta.glob<{ default: ImageMetadata }>( "/src/assets/*/map_.png", );
return await images[`/src/assets/${saveTo}/${imageFile}`]();
So far the idea.
But glob does not list the freshly generated file. It is not in the images array.
I get this error:
images[saveTo2imageFile] is not a function
It might has something to do with static import of glob which is not able to reflect changes at runtime?
How can i dynamically import the generated image?
Upvotes: 0
Views: 48