-
Notifications
You must be signed in to change notification settings - Fork 26
/
vite.config.ts
73 lines (63 loc) · 1.43 KB
/
vite.config.ts
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
import childProcess from 'node:child_process';
import { fileURLToPath } from 'node:url';
import vue from '@vitejs/plugin-vue2';
import { visualizer } from 'rollup-plugin-visualizer';
import { defineConfig } from 'vite';
const manualChunks = (id: string) => {
// Bootstrap
if (id.includes('bootstrap')) {
return 'bootstrap';
}
// Ace
if (id.includes('ace')) {
return 'ace-builds';
}
// Lodash
if (id.includes('lodash')) {
return 'lodash';
}
// Vue and plugins
if (id.includes('vue')) {
return 'vue';
}
// Apex charts and Leaflet
if (id.includes('apexcharts') || id.includes('leaflet')) {
return 'charts-maps';
}
// Other dependencies
if (id.includes('node_modules')) {
return 'vendor';
}
};
let commitHash = 'unknown commit';
try {
commitHash = childProcess.execSync('git rev-parse --short HEAD').toString().trim();
} catch (error) {
console.warn(`Could not get the commit hash: ${error}`);
}
// https://vitejs.dev/config/
export default defineConfig({
build: {
rollupOptions: {
output: {
manualChunks,
},
},
},
define: {
'__APP_VERSION__': JSON.stringify(process.env.npm_package_version),
'__COMMIT_HASH__': JSON.stringify(commitHash),
},
plugins: [vue(), visualizer()],
preview: {
port: 8080,
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
port: 8080,
},
});