Skip to content

@islands/images: Asset URL transformation in a custom Picture component #92

Answered by ElMassimo
lutuh asked this question in Q&A
Discussion options

You must be logged in to vote

@lutuh You are looking for the transform Vue performs to extract src and srcset urls as imports, which can be configured manually by providing template.transformAssetUrls.tags to @vitejs/plugin-vue.

Since Vite doesn't seem to combine these options, you might need to provide all of the ones you intend to use, in addition to your CustomPicture: ['src'],.


An example custom component I'm using in some of my sites, which uses the Picture component internally:

<script setup lang="ts">
import { useAttrs } from 'vue'

const attrs = useAttrs()

const props = defineProps({
  src: { type: [String, Array], required: true },
  narrow: { type: Boolean, default: false },
  square: { type: Boolean, defa…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ElMassimo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants