-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
34 lines (32 loc) · 1.07 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
import { loadEnv } from 'vite';
import commonjs from 'vite-plugin-commonjs';
import react from '@vitejs/plugin-react-swc';
import { defineConfig } from 'vitest/config';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
export default defineConfig(({ mode }) => {
// Load environment variables based on the mode
const env = loadEnv(mode, process.cwd(), '');
return {
base: '/',
plugins: [react(), commonjs(), nodePolyfills()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/setupTests.ts',
css: true,
reporters: ['verbose'],
coverage: {
reporter: ['text', 'json', 'html'],
include: ['src/**/*'],
exclude: [],
}
},
define: {
'process.env': env, // Pass all env variables to process.env
global: 'globalThis',
},
server: {
port: env.VITE_APP_PORT ? parseInt(env.VITE_APP_PORT) : 3000, // Default to 3000 if not set
}
};
});