-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
54 lines (50 loc) · 1.3 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
/// <reference types="vitest" />
import { execSync } from 'child_process';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import checker from 'vite-plugin-checker';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';
function getNodeEnv(command: 'build' | 'serve') {
return command === 'build' ? 'production' : 'development';
}
function git(command: string) {
return execSync(`git ${command}`, { encoding: 'utf8' }).trim();
}
// https://vitejs.dev/config/
export default defineConfig(({ command }) => ({
plugins: [
react(),
svgr({
exportAsDefault: true,
}),
tsconfigPaths(),
checker({
typescript: {
tsconfigPath: './tsconfig.json',
},
eslint: {
lintCommand: 'eslint ./src/**/*.{ts,tsx}"',
dev: { logLevel: ['error'] },
},
enableBuild: false,
}),
],
define: {
'process.env.NODE_ENV': JSON.stringify(getNodeEnv(command)),
'import.meta.env.VITE_APP_VERSION': JSON.stringify(
process.env.npm_package_version
),
'import.meta.env.VITE_COMMIT_HASH': JSON.stringify(
git('rev-parse --short HEAD')
),
},
build: {
sourcemap: true,
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['vitest.setup.ts'],
},
}));