Skip to content

开起 cache: false, ts使用的资源路径会不正确。 #210

@Asx-xy

Description

@Asx-xy

Steps to reproduce

vite.config.ts

export default defineConfig({
  plugins: [
    vue(),
    imagemin({cache: false}),
]

// vue文件

<script setup lang="ts">
import img39 from '@/assets/images/39.jpg?url'
const imgSrc38 = new URL(`../assets/images/38.jpg`, import.meta.url).href
</script>

<template>
  <div>
    <img src="@/assets/images/37.jpg" class="w-400" />
    <img :src="imgSrc38" class="w-400 mt-20" />
    <img :src="img39" class="w-400 mt-20" />
  </div>
</template>
pnpm run build
pnpm run preview

result:
imgSrc38 img39 not work

Image

What is expected?

希望可以正常工作或应该如何更改才能使用。

What is actually happening?

不开启cache:false 的第一次也会有这个问题,第二次就好了。

System Info

Any additional comments?

No response

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