-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathvite.config.ts
48 lines (44 loc) · 1.03 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
import { sveltekit } from '@sveltejs/kit/vite';
import type { PluginOption, UserConfig } from 'vite';
import { resolve } from 'path';
import istanbul from 'vite-plugin-istanbul';
const plugins: PluginOption[] = [sveltekit()];
if (process.env.NODE_ENV?.toLowerCase() === 'test') {
plugins.push(
istanbul({
include: ['src/**/*.ts', 'src/**/*.js', 'src/**/*.svelte'],
exclude: ['node_modules', 'tests/'],
extension: ['.js', '.ts', '.svelte'],
requireEnv: false,
forceBuildInstrument: true,
nycrcPath: './.nycrc.json',
})
);
} else {
plugins.push({
name: 'remove-testids',
enforce: 'pre',
transform(code, id) {
if (id.endsWith('.svelte')) {
return code.replace(/data-testid=".*?"/g, '');
}
return code;
},
});
}
const config: UserConfig = {
plugins,
test: {
include: ['src/**/*.{test,spec}.{js,ts}'],
},
server: {
host: '0.0.0.0',
},
resolve: {
alias: {
$: resolve('./src'),
'.prisma/client/index-browser': './node_modules/.prisma/client/index-browser.js',
},
},
};
export default config;