-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvite.config.ts
43 lines (37 loc) · 1.06 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
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
const defaultConfig = {
plugins: [tsconfigPaths(), react()],
}
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
// process.env = { ...process.env, ...loadEnv(mode, process.cwd(), '') };
process.env = Object.assign(process.env, loadEnv(mode, process.cwd()));
// dev specific config
if (command === 'serve') {
return {
...defaultConfig,
test: {
environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'],
},
server: {
open: Boolean(process.env.VITE_OPEN),
host: true,
port: +process.env.VITE_PORT!,
},
};
} else {
// command === 'build'
return {
...defaultConfig,
build: {
outDir: './build',
emptyOutDir: true
},
};
}
});