-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
63 lines (59 loc) · 1.8 KB
/
vite.config.ts
File metadata and controls
63 lines (59 loc) · 1.8 KB
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
import { svelteTesting } from '@testing-library/svelte/vite';
import tailwindcss from '@tailwindcss/vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { execSync } from 'child_process';
import { readFileSync } from 'fs';
// Get version from package.json
const packageJson = JSON.parse(readFileSync('./package.json', 'utf-8'));
const version = packageJson.version;
// Get git commit hash
let gitCommit = 'unknown';
try {
gitCommit = execSync('git rev-parse --short HEAD').toString().trim();
} catch (error) {
console.warn('Could not get git commit hash:', error);
}
// Get git branch
let gitBranch = 'unknown';
try {
gitBranch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
} catch (error) {
console.warn('Could not get git branch:', error);
}
export default defineConfig({
server: { port: 5200 },
define: {
__APP_VERSION__: JSON.stringify(version),
__GIT_COMMIT__: JSON.stringify(gitCommit),
__GIT_BRANCH__: JSON.stringify(gitBranch),
__BUILD_TIME__: JSON.stringify(new Date().toISOString())
},
plugins: [tailwindcss(), sveltekit()],
test: {
workspace: [
{
extends: './vite.config.ts',
plugins: [svelteTesting()],
test: {
name: 'client',
environment: 'jsdom',
clearMocks: true,
include: ['src/**/*.svelte.{test,spec}.{js,ts}', 'test/**/*.svelte.{test,spec}.{js,ts}'],
exclude: ['src/lib/server/**'],
setupFiles: ['./vitest-setup-client.ts', './test/setup.ts']
}
},
{
extends: './vite.config.ts',
test: {
name: 'server',
environment: 'node',
include: ['src/**/*.{test,spec}.{js,ts}', 'test/**/*.{test,spec}.{js,ts}'],
exclude: ['src/**/*.svelte.{test,spec}.{js,ts}', 'test/**/*.svelte.{test,spec}.{js,ts}'],
setupFiles: ['./test/setup-server.ts']
}
}
]
}
});