Skip to content

Instantly share code, notes, and snippets.

@drjamesj
Last active March 9, 2024 19:06
Show Gist options
  • Save drjamesj/57decae087599ea8e4e41e0ee8477905 to your computer and use it in GitHub Desktop.
Save drjamesj/57decae087599ea8e4e41e0ee8477905 to your computer and use it in GitHub Desktop.
Use vite-imagetools in SvelteKit
<script>
import MyFancyImg from '$lib/images/large_image.png?w=400&format=webp';
</script>
<img
alt="Here is my optimised image in next gen format"
width="400"
height="400"
src={MyFancyImg}
/>
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { imagetools } from 'vite-imagetools';
export default defineConfig({
plugins: [sveltekit(), imagetools()]
});
@drjamesj
Copy link
Author

drjamesj commented Feb 11, 2024

npm install vite-imagetools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment