-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
50 lines (46 loc) · 1.22 KB
/
vite.config.ts
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
import { paraglide } from '@inlang/paraglide-js-adapter-vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
import { imagetools } from 'vite-imagetools';
import Icons from 'unplugin-icons/vite';
const supportedExtensions = ['png', 'jpg', 'jpeg'];
const defaultImageToolsWidth = '320;640;1280';
export default defineConfig(({ mode }) => {
return {
plugins: [
sveltekit(),
imagetools({
defaultDirectives: (url) => {
const extension = url.pathname.substring(url.pathname.lastIndexOf('.') + 1);
if (supportedExtensions.includes(extension)) {
const width = url.searchParams.get('w') ?? undefined;
return new URLSearchParams({
format: 'avif;webp;' + extension,
w: width ?? defaultImageToolsWidth,
as: 'picture'
});
}
return new URLSearchParams();
}
}),
paraglide({
project: './project.inlang',
outdir: './src/lib/libs/i18n/messages'
}),
Icons({
compiler: 'svelte',
defaultClass: 'size-6'
})
],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
server: {
port: 3000,
host: '0.0.0.0'
},
esbuild: {
drop: mode === 'production' ? ['console', 'debugger'] : []
}
};
});