Skip to content

Commit

Permalink
chore: upgrade to vite-imagetools 5 (#10143)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored Jun 14, 2023
1 parent 6d8d62e commit b43ea97
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"tiny-glob": "^0.2.9",
"typescript": "^4.9.4"
},
"packageManager": "pnpm@8.6.1",
"packageManager": "pnpm@8.6.2",
"engines": {
"pnpm": "^8.0.0"
}
Expand Down
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sites/kit.svelte.dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"tiny-glob": "^0.2.9",
"typescript": "^4.9.4",
"vite": "^4.3.6",
"vite-imagetools": "^4.0.19",
"vite-imagetools": "^5.0.4",
"vitest": "^0.31.0"
},
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion sites/kit.svelte.dev/src/lib/Image.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
{#each Object.entries(src.sources) as [format, images]}
<source srcset={images.map((i) => `${i.src} ${i.w}w`).join(', ')} type={'image/' + format} />
{/each}
<img src={src.fallback.src} {alt} {...$$restProps} />
<img src={src.img.src} {alt} {...$$restProps} />
</picture>
{/if}
7 changes: 1 addition & 6 deletions sites/kit.svelte.dev/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ const config = {
imagetools({
defaultDirectives: (url) => {
const ext = path.extname(url.pathname);
const params = new URLSearchParams();
params.set('format', 'avif;webp;' + fallback[ext]);
if (!params.has('meta') && !params.has('metadata') && !params.has('source') && !params.has('srcset') && !params.has('url')) {
params.set('picture', true);
}
return params;
return new URLSearchParams(`format=avif;webp;${fallback[ext]}&as=picture`);
}
}),
sveltekit()
Expand Down

0 comments on commit b43ea97

Please sign in to comment.