I have a directory outside my project root, which I've symlinked to ./src/assets/external From here, I have /midelco/uploads which holds my product images. I added preserveSymlinks in my Vite config too.
I even symlinked the same directory structure in my local environment to verify it's working.
In my code I have:
const allImages = import.meta.glob<{ default: ImageMetadata }>("/src/assets/external/midelco/uploads/*.{jpeg,jpg,png,JPG}");
Which returns the images in that directory:
all images: {
'/src/assets/external/midelco/uploads/29138_0.jpg': [Function: /src/assets/external/midelco/uploads/29138_0.jpg],
'/src/assets/external/midelco/uploads/29138_1.jpg': [Function: /src/assets/external/midelco/uploads/29138_1.jpg],
'/src/assets/external/midelco/uploads/29138_2.jpg': [Function: /src/assets/external/midelco/uploads/29138_2.jpg]
}
But on production, this is always an empty array. It has the same directory structure, and I use a pre-build script that creates the symlink before the build starts.
I SSH'ed in and see the symlink present with the matching directory structure, and images.
Yet, the glob returns empty....