-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.js
49 lines (46 loc) · 1.18 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
import path from 'path';
import { searchForWorkspaceRoot } from 'vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { exec } from 'child_process';
import { promisify } from 'util';
// https://stackoverflow.com/a/70069241
// Get current tag/commit and last commit date from git
const pexec = promisify(exec);
let [version, lastmod] = (
await Promise.allSettled([
pexec('git fetch --tags && git describe --tags || git rev-parse --short HEAD'),
pexec('git log -1 --format=%cd --date=format:"%Y-%m-%d %H:%M"')
])
).map((v) => JSON.stringify(v.value?.stdout.trim()));
/**
* @type {import('vite').UserConfig}
*/
const config = {
define: {
__VERSION__: version,
__LASTMOD__: lastmod
},
plugins: [sveltekit()],
resolve: {
alias: {
$src: path.resolve('./src'),
$comps: path.resolve('./src/lib/components')
}
},
server: {
fs: {
allow: [searchForWorkspaceRoot(process.cwd())]
}
},
build: {
target: 'esnext',
chunkSizeWarningLimit: 1024
},
test: {
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
globals: true,
environment: 'jsdom',
setupFiles: 'setupTest.cjs'
}
};
export default config;