vite-plugin-vue
vite-plugin-vue copied to clipboard
vite4 use alias , inline style background-image cannot worked.
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
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
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>
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.