-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
83 lines (79 loc) · 2.03 KB
/
vite.config.ts
File metadata and controls
83 lines (79 loc) · 2.03 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/// <reference types="vitest" />
import * as path from 'path';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite'
import { defineConfig, loadEnv } from 'vite';
import { createHtmlPlugin } from 'vite-plugin-html';
import { execSync } from 'child_process'
let commitHash = 'unknown'
let lastUpdate = 'unknown'
try {
commitHash = execSync('git rev-parse --short HEAD').toString().trim();
lastUpdate = execSync('git log -1 --format=%cd --date=iso-local').toString().trim();
lastUpdate = new Date(lastUpdate).toLocaleString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
timeZoneName: 'short',
});
} catch (e) {
console.warn('Unable to determine git info');
}
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), 'VITE_')
return {
plugins: [
createHtmlPlugin({
inject: {
data: {
VITE_GA_MEASUREMENT_ID: env.VITE_GA_MEASUREMENT_ID || '',
}
},
}),
react(),
tailwindcss(),
],
define: {
global: 'globalThis',
'process.env': env,
__COMMIT_HASH__: JSON.stringify(commitHash),
__LAST_UPDATE__: JSON.stringify(lastUpdate),
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
sourcemap: false,
rollupOptions: {
output: {
entryFileNames: 'assets/[name].[hash].js',
chunkFileNames: 'assets/[name].[hash].js',
assetFileNames: 'assets/[name].[hash].[ext]',
},
},
},
server: {
port: 3001,
proxy: {
'/api/hoodi': {
target: env.VITE_HOODI_API_URL,
changeOrigin: true,
secure: true,
},
'/api/mainnet': {
target: env.VITE_MAINNET_API_URL,
changeOrigin: true,
secure: true,
},
},
},
test: {
root: path.resolve(__dirname, './src'),
},
}
});