24 lines
653 B
TypeScript
24 lines
653 B
TypeScript
import { sveltekit } from '@sveltejs/kit/vite';
|
|
import { imagetools } from 'vite-imagetools';
|
|
import { defineConfig } from 'vite';
|
|
|
|
const supportedExtensions = ['png', 'jpg', 'jpeg'];
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
imagetools({
|
|
defaultDirectives: (url) => {
|
|
const extension = url.pathname.substring(
|
|
url.pathname.lastIndexOf('.') + 1
|
|
);
|
|
if (supportedExtensions.includes(extension)) {
|
|
return new URLSearchParams({
|
|
format: 'avif;webp;' + extension,
|
|
// picture: true
|
|
});
|
|
}
|
|
return new URLSearchParams();
|
|
}
|
|
}),
|
|
sveltekit()]
|
|
});
|