This repository was archived by the owner on Apr 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
58 lines (53 loc) · 1.65 KB
/
vite.config.ts
File metadata and controls
58 lines (53 loc) · 1.65 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
import graphql from '@rollup/plugin-graphql';
import react from '@vitejs/plugin-react-swc';
import * as childProcess from 'child_process';
// @ts-ignore
import dns from 'dns';
import { defineConfig, loadEnv } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import checker from 'vite-plugin-checker';
import buildInject from './vite-plugins/buildInject';
dns.setDefaultResultOrder('verbatim');
const gitShortCommitHash = childProcess
.execSync('git rev-parse --short HEAD')
.toString()
.trim();
const gitLongCommitHash = childProcess
.execSync('git rev-parse HEAD')
.toString()
.trim();
// https://vitejs.dev/config/
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return defineConfig({
server: {
port: 3000,
},
build: {
outDir: 'build',
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes('node_modules')) {
return 'vendor';
}
},
},
},
sourcemap: JSON.parse(
process.env.VITE_ENABLE_SOURCE_MAP || 'false',
),
},
plugins: [
checker({ typescript: true }),
buildInject(),
tsconfigPaths(),
react(),
graphql(), // support importing .graphql files
],
define: {
GIT_SHORT_COMMIT_HASH: JSON.stringify(gitShortCommitHash),
GIT_LONG_COMMIT_HASH: JSON.stringify(gitLongCommitHash),
},
});
};