-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
35 lines (34 loc) · 988 Bytes
/
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
/// <reference types="vitest" />
import { loadEnv } from 'vite'
import type { ConfigEnv, UserConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'
import { parseEnv } from './src/utils/parseEnv'
export default ({ mode }: ConfigEnv): UserConfig => {
const root = process.cwd()
const env = loadEnv(mode, root)
const { VITE_PORT, VITE_DROP_CONSOLE, VITE_DROP_DEBUGGER, VITE_PUBLIC_PATH = '/' } = parseEnv(env)
const drop = [VITE_DROP_CONSOLE ? 'console' : '', VITE_DROP_DEBUGGER ? 'debugger' : ''].filter(Boolean)
return {
base: VITE_PUBLIC_PATH,
root,
server: {
host: true,
port: Number(VITE_PORT),
},
build: {
reportCompressedSize: false,
chunkSizeWarningLimit: 2000,
},
esbuild: {
// @ts-expect-error
drop,
},
// @ts-expect-error
plugins: [react(), tsconfigPaths()],
test: {
environment: 'happy-dom',
globals: true,
},
}
}