Run build + Serve dist folder (I used vscode liveServer)
What is expected?
<template>
<img alt="Vue logo" :src="require('../assets/logo.png')" />
<!-- This works with serve and with build -->
<img alt="Vue logo" :src="require('../assets/' + imageSrc)" />
<!-- This works with serve not with build -> ReferenceError: _unref is not defined -->
<img alt="Vue logo" :src="require(`../assets/${imageSrc}`)" />
</template>
<script setup lang="ts">
import { computed } from 'vue';
const imageSrc = computed(() => { return 'logo.png' })
</script>
This component should display the vue logo 3 times independent of development/production build.
What is actually happening?
The third image leads to an error in production build:
ReferenceError: _unref is not defined
If you comment out the last image tag both serve and build are working fine and display two images.
Version
4.5.13
Reproduction link
github.com
Environment info
Steps to reproduce
Clone Repository
Run serve
Run build + Serve dist folder (I used vscode liveServer)
What is expected?
This component should display the vue logo 3 times independent of development/production build.
What is actually happening?
The third image leads to an error in production build:
ReferenceError: _unref is not defined
If you comment out the last image tag both serve and build are working fine and display two images.