-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
64 lines (61 loc) · 1.85 KB
/
vite.config.js
File metadata and controls
64 lines (61 loc) · 1.85 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
57
58
59
60
61
62
63
64
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'node:path';
import { execSync } from 'node:child_process';
// Custom plugin to inject commit hash
function commitHashPlugin() {
return {
name: 'commit-hash',
config(config, { command }) {
// Get current commit hash
let commitHash = 'unknown';
try {
commitHash = execSync('git rev-parse --short HEAD', { encoding: 'utf8' }).trim();
} catch (error) {
console.warn('Failed to get git commit hash:', error.message);
}
// Inject as environment variable
config.define = {
...config.define,
__COMMIT_HASH__: JSON.stringify(commitHash),
};
},
};
}
export default defineConfig({
plugins: [react(), commitHashPlugin()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
// Ensure every import (including inside external libs) resolves to the SAME
// instance of React / React-DOM so that hooks work correctly.
react: path.resolve(__dirname, 'node_modules/react'),
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
'react/jsx-runtime': path.resolve(__dirname, 'node_modules/react/jsx-runtime')
},
},
// Prevent Vite from pre-bundling its own duplicate react copies
optimizeDeps: {
include: ['react', 'react-dom'],
dedupe: ['react', 'react-dom'],
},
server: {
port: 9021,
allowedHosts: ['anycast.dread.technology', 'cast.dread.technology', 'localhost', 'breadcast.ai', '*'],
proxy: {
'/api': {
target: 'http://localhost:3001',
changeOrigin: true,
},
'/generated': {
target: 'http://localhost:3001',
changeOrigin: true,
},
'/ws': {
target: 'ws://localhost:3001',
ws: true,
changeOrigin: true,
},
},
},
});