-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.js
54 lines (49 loc) · 1.16 KB
/
vite.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import imagePresets, { densityPreset, widthPreset } from 'vite-plugin-image-presets';
import { sveltekit } from '@sveltejs/kit/vite';
const withRoundBorders = (image) => {
const { width } = image.options;
const rectFor = (width, height = width) =>
Buffer.from(
`<svg><rect x="0" y="0" width="${width}" height="${height}" rx="${width}" ry="${height}"/></svg>`
);
return image
.resize({ width, height: width, fit: 'cover' })
.composite([{ input: rectFor(width), blend: 'dest-in' }]);
};
/** @type {import('@sveltejs/kit').Config} */
const config = {
plugins: [
imagePresets({
logo: densityPreset({
class: 'img density',
height: 16, // avoid layout shift
baseWidth: 16,
density: [1, 1.5, 2],
resizeOptions: {
fit: 'cover'
},
withImage: withRoundBorders,
formats: {
webp: { quality: 40 },
png: { quality: 40 }
}
}),
thumbnail: widthPreset({
loading: 'lazy',
widths: [50, 300],
formats: {
webp: { quality: 90 }
}
}),
hd: widthPreset({
loading: 'lazy',
widths: [50, 300, 1024],
formats: {
webp: { quality: 90 }
}
})
}),
sveltekit()
]
};
export default config;