Skip to content

[Astro] Images not found after build #808

@techpoint24de

Description

@techpoint24de

Using unpic with Astro breaks after running build.
In dev all images are loaded and the placeholders are working but after building the images are not served anymore.

Path after build: http://localhost:4321/_image?w=1920&h=1280&fit=cover&href=%2F_astro%2F8.B51ZUIHt.jpg

The images are in ./src/assets/images

Astro config

import { imageService } from "@unpic/astro/service";

[...]

image: {
    service: imageService(),
},

[...]

Image component (dynamically imported images using import.meta.glob())

import { Image } from "@unpic/astro";

[...]

const placeholder = blurhashToCssGradientString(blurHashes[index]);

[...]

<Image
    src={imageData.default.src}
    width={imageData.default.width}
    height={imageData.default.height}
    alt="Photo by XYZ"
    class="w-full h-auto object-cover rounded-xl"
    placeholder={placeholder}
/>

[...]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions