-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathvite.config.ts
More file actions
49 lines (45 loc) · 1.07 KB
/
vite.config.ts
File metadata and controls
49 lines (45 loc) · 1.07 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
import ViteYaml from '@modyfi/vite-plugin-yaml';
import react from '@vitejs/plugin-react';
import { execSync } from 'child_process';
import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
import viteTsconfigPaths from 'vite-tsconfig-paths';
function getGitCommitHash() {
return execSync('git rev-parse --short HEAD').toString().trim();
}
function getGitTag() {
try {
return execSync('git describe --tags --abbrev=0').toString().trim();
} catch {
return null;
}
}
const GIT_COMMIT = getGitCommitHash();
const GIT_TAG = getGitTag();
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
viteTsconfigPaths(),
ViteYaml(),
VitePWA({
registerType: 'autoUpdate',
devOptions: {
enabled: true,
},
}),
],
build: {
rollupOptions: {
output: {
manualChunks: {
react: ['react', 'react-dom', 'react-router-dom'],
},
},
},
},
define: {
__GIT_COMMIT__: JSON.stringify(GIT_COMMIT),
__GIT_TAG__: JSON.stringify(GIT_TAG || ''),
},
});