-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
56 lines (53 loc) · 1.56 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
55
56
/// <reference types="./src/env.d.ts"/>
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
import { UserConfigExport, defineConfig, loadEnv } from 'vite';
import checker from 'vite-plugin-checker';
import istanbul from 'vite-plugin-istanbul';
// https://vitejs.dev/config/
const config = ({ mode }: { mode: string }): UserConfigExport => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
// this defines if we should automatically open the browser
const shouldOpen = process.env.BROWSER && process.env.BROWSER !== 'none';
return defineConfig({
base: '',
server: {
port: parseInt(process.env.VITE_PORT || '3001', 10),
open: shouldOpen,
watch: {
ignored: ['**/coverage/**', '**/cypress/downloads/**'],
},
},
preview: {
port: parseInt(process.env.VITE_PORT || '3001', 10),
open: shouldOpen,
},
build: {
outDir: 'build',
sourcemap: true,
},
plugins: [
mode === 'test'
? // in test mode we instrument the code
istanbul({
include: 'src/*',
exclude: ['node_modules', 'test/'],
extension: ['.js', '.ts', '.tsx'],
cypress: true,
forceBuildInstrument: true,
})
: // in dev mode we run the checker
checker({
typescript: true,
eslint: { lintCommand: 'eslint "./**/*.{ts,tsx}"' },
}),
react(),
],
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
});
};
export default config;