vite-plugin-vue icon indicating copy to clipboard operation
vite-plugin-vue copied to clipboard

vite4 use alias , inline style background-image cannot worked.

Open wensc1996 opened this issue 2 years ago • 2 comments

Describe the bug

// vite.config.ts alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) }

// index.vue - useless

<div
    style="
      height: 400px;
      width: 400px;
      background-image: url(@/assets/006APoFYly1goh7pmtqjbj30c80con1u.jpg);
    "
  >

// in this case, open brower net record can see the source link same as @/assets/006APoFYly1goh7pmtqjbj30c80con1u.jpg, never convert

// index.vue - worked <img src="@/assets/006APoFYly1goh7pmtqjbj30c80con1u.jpg" alt="" />

Reproduction

https://codesandbox.io/s/epic-smoke-wkr3ky?file=/src/pages/Index.vue

Steps to reproduce

open can see

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (4) x64 Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz   
    Memory: 3.78 GB / 15.80 GB
  Binaries:
    Node: 16.3.0 - D:\nodev16\node.EXE
    npm: 7.15.1 - D:\nodev16\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (110.0.1587.46)

Used Package Manager

npm

Logs

No response

Validations

wensc1996 avatar Feb 17 '23 09:02 wensc1996

This is not supported. You'll need to resolve on your side.

<template>
  <div
    :style="`
      height: 400px;
      width: 400px;
      background-image: url(${u});
    `"
  >
</template>
<script setup>
import u from '@/assets/006APoFYly1goh7pmtqjbj30c80con1u.jpg'
</script>

sapphi-red avatar Feb 17 '23 17:02 sapphi-red

This is not supported. You'll need to resolve on your side.

<template>
  <div
    :style="`
      height: 400px;
      width: 400px;
      background-image: url(${u});
    `"
  >
</template>
<script setup>
import u from '@/assets/006APoFYly1goh7pmtqjbj30c80con1u.jpg'
</script>

OK, thanks, acutually now it's better than before so much.

wensc1996 avatar Feb 20 '23 06:02 wensc1996