You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: packages/plugin-vue/README.md
+35-8
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,40 @@ export interface Options {
51
51
}
52
52
```
53
53
54
+
## Asset URL handling
55
+
56
+
When `@vitejs/plugin-vue` compiles the `<template>` blocks in SFCs, it also converts any encountered asset URLs into ESM imports.
57
+
58
+
For example, the following template snippet:
59
+
60
+
```vue
61
+
<img src="../image.png" />
62
+
```
63
+
64
+
Is the same as:
65
+
66
+
```vue
67
+
<script setup>
68
+
import _imports_0 from '../image.png'
69
+
</script>
70
+
71
+
<img src="_imports_0" />
72
+
```
73
+
74
+
By default the following tag/attribute combinations are transformed, and can be configured using the `template.transformAssetUrls` option.
75
+
76
+
```js
77
+
{
78
+
video: ['src', 'poster'],
79
+
source: ['src'],
80
+
img: ['src'],
81
+
image: ['xlink:href', 'href'],
82
+
use: ['xlink:href', 'href']
83
+
}
84
+
```
85
+
86
+
Note that only attribute values that are static strings are transformed. Otherwise, you'd need to import the asset manually, e.g. `import imgUrl from '../image.png'`.
87
+
54
88
## Example for passing options to `vue/compiler-sfc`:
0 commit comments