-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
56 lines (53 loc) · 1.83 KB
/
Copy pathvite.config.ts
File metadata and controls
56 lines (53 loc) · 1.83 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
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import fs from 'fs';
import path from 'path';
import {defineConfig} from 'vite';
const packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf-8')) as { version?: string };
function getDisplayVersion() {
const githubTag = process.env.GITHUB_REF_TYPE === 'tag' ? process.env.GITHUB_REF_NAME : undefined;
const rawVersion = githubTag || packageJson.version || '0.1.2';
return rawVersion.startsWith('v') ? rawVersion : `v${rawVersion}`;
}
export default defineConfig(() => {
return {
plugins: [react(), tailwindcss()],
define: {
__APP_VERSION__: JSON.stringify(getDisplayVersion()),
},
resolve: {
alias: {
'@': path.resolve(__dirname, '.'),
},
},
server: {
// HMR can be disabled via DISABLE_HMR in constrained editing environments.
// File watching may be disabled to reduce flicker during agent-driven edits.
hmr: process.env.DISABLE_HMR !== 'true',
// Disable file watching when DISABLE_HMR is true to reduce CPU usage.
watch: process.env.DISABLE_HMR === 'true' ? null : {},
},
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes('node_modules')) return undefined;
if (id.includes('react-dom') || id.includes(`${path.sep}react${path.sep}`)) {
return 'vendor-react';
}
if (id.includes('@tiptap') || id.includes('prosemirror')) {
return 'vendor-editor';
}
if (id.includes('@xyflow')) {
return 'vendor-flow';
}
if (id.includes('lucide-react')) {
return 'vendor-icons';
}
return 'vendor-misc';
},
},
},
},
};
});