generated from dvcol/svelte-lib-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
72 lines (64 loc) · 1.67 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { fileURLToPath, URL } from 'url';
import { sveltekit } from '@sveltejs/kit/vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { svelteTesting } from '@testing-library/svelte/vite';
import { sveltePreprocess } from 'svelte-preprocess';
import { checker } from 'vite-plugin-checker';
import { defineConfig, type ViteUserConfig } from 'vitest/config';
import type { PluginOption } from 'vite';
const plugins: PluginOption[] = [];
const isTest = process.env.NODE_ENV === 'test';
const isDev = process.env.NODE_ENV === 'development';
const isWeb = process.env.VITE_MODE === 'WEB';
if (isDev) {
plugins.push(
svelte({
preprocess: sveltePreprocess(),
}),
checker({
typescript: {
tsconfigPath: 'tsconfig.json',
},
}),
);
} else if (isWeb) {
plugins.push(
svelte({
preprocess: sveltePreprocess(),
}),
);
} else {
plugins.push(sveltekit());
}
if (isTest) {
plugins.push(svelteTesting());
}
const config: ViteUserConfig = {
plugins,
resolve: {
alias: {
'~': fileURLToPath(new URL('./src/lib', import.meta.url)),
src: fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
port: 3303,
open: '/neo-svelte/',
},
preview: {
port: 3304,
open: '/neo-svelte/',
},
test: {
include: ['test/**/*.{test,spec}.{js,ts}'],
exclude: ['test/setup.test.ts'],
environment: 'jsdom',
setupFiles: ['/test/setup.test.ts'],
alias: {
'~/': fileURLToPath(new URL('./src/lib', import.meta.url)),
'src/': fileURLToPath(new URL('./src', import.meta.url)),
},
},
};
if (isWeb) config.base = '/neo-svelte/';
export default defineConfig(config);