Description
openedon Sep 26, 2023
I'm using Nuxt 3.7.3, Nuxt image 1.0.0-rc.2
In a component, providing image from assets directory as src prop of does not render image, I see "404 IPX: File not found" error in JS console.
Same image with <img>
tag works correctly.
This works:
<img src="~/assets/img/banners/front-page-banner.png" alt="Banner" />
This does not work:
<NuxtImg src="~/assets/img/banners/front-page-banner.png" alt="Banner" />
Import also does not work. This does not work:
<script lang="ts" setup>
import banner from '~/assets/img/banners/front-page-banner.png';
</script>
<template>
<NuxtImg :src="banner" alt="Banner" />
</template>
According documentation https://image.nuxt.com/get-started/configuration#dir I've added assets directory to nuxt.config:
dir: 'assets/img'
Now image is rendered normally using it this way:
<NuxtImg src="banners/front-page-banner.png" alt="Banner" />
But only on local development server, after building and deploying it image is not rendered and same error appears in JS console.