This repository has been archived by the owner on Jan 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
77 lines (71 loc) · 1.84 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
73
74
75
76
77
import { exec } from 'child_process';
import { promisify } from 'util';
import { sentrySvelteKit } from '@sentry/sveltekit';
import { sveltekit } from '@sveltejs/kit/vite';
import { imagetools } from '@zerodevx/svelte-img/vite';
import { sitemapPlugin } from 'sveltekit-sitemap/dist/plugin';
import { plugin as mdPlugin, Mode as mdMode } from 'vite-plugin-markdown';
import { watch } from 'vite-plugin-watch';
import { defineConfig } from 'vitest/config';
import { name } from './package.json';
// get current tag/commit and last commit date from git
const pexec = promisify(exec);
const [versionTag, commitHash, lastModified] = (
await Promise.allSettled([
pexec('git describe --tags --dirty --always'),
pexec('git rev-parse --short HEAD'),
pexec('git log -1 --format=%cd --date=format:"%Y-%m-%d %H:%M"')
])
).map((v) => {
if (v.status !== 'rejected') {
return v.value?.stdout.trim();
}
return null;
});
export default defineConfig(({ command }) => ({
plugins: [
sentrySvelteKit({
autoInstrument: false, // reset when Sentry fixed issues with Cloudflare Page
sourceMapsUploadOptions: {
org: 'sxya',
project: 'vegas'
}
}),
sveltekit(),
imagetools(),
mdPlugin({ mode: [mdMode.HTML, mdMode.TOC] }),
command === 'build' && sitemapPlugin(),
watch({
pattern: 'i18n/*.json',
command: 'pnpm run i18n:compile'
}),
{
name: 'compile-i18n',
async buildStart() {
if (command === 'build') {
await pexec('pnpm run i18n:compile');
}
}
}
],
server: {
proxy: {
'/apid': {
target: 'https://apid.sxya.org',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/apid/, '')
}
}
},
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
define: {
__APPNAME__: JSON.stringify(name),
__VERSION__: JSON.stringify({
tag: versionTag,
hash: commitHash,
date: lastModified
})
}
}));