Skip to content

IPX: File not found when using assets directory #1006

Open
@alex-lmt

Description

@alex-lmt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions