This repository was archived by the owner on Feb 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.js
More file actions
50 lines (46 loc) · 1.37 KB
/
vite.config.js
File metadata and controls
50 lines (46 loc) · 1.37 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
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { execSync } from 'child_process'
// Get git commit hash
let gitHash = 'unknown'
try {
gitHash = execSync('git rev-parse --short HEAD', {
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'ignore']
}).trim()
} catch (e) {
console.warn('Could not get git hash')
}
const shutdownPlugin = {
name: 'shutdown-plugin',
apply: 'serve',
configureServer(server) {
return () => {
server.httpServer?.on('request', (req, res) => {
if (req.url === '/api/shutdown' && (req.method === 'POST' || req.method === 'GET')) {
console.log('[Shutdown] Intercepted request');
// Only write if headers haven't been sent
if (!res.headersSent) {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'Shutting down...' }));
} else {
res.end();
}
setTimeout(() => {
console.log('[Shutdown] Killing server');
process.exit(0);
}, 200);
return;
}
});
};
}
};
// https://vite.dev/config/
export default defineConfig({
plugins: [svelte(), shutdownPlugin],
base: "/fatuus/",
define: {
__GIT_HASH__: JSON.stringify(gitHash)
}
})