-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.test.ts
81 lines (79 loc) · 2.19 KB
/
vite.config.test.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { lingui } from '@lingui/vite-plugin'
import react from '@vitejs/plugin-react-swc'
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
import svgr from 'vite-plugin-svgr'
// https://vitejs.dev/config/
export default defineConfig(({ 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.
const env = loadEnv(mode, process.cwd(), '')
return {
base: process.env.PUBLIC_URL ?? '/',
plugins: [
react({ plugins: [['@lingui/swc-plugin', {}]] }),
svgr(),
lingui(),
// mockDevServerPlugin({
// prefix: '/api',
// wsPrefix: '^/api/workspaces/[a-z0-9\\-]+/events',
// include: ['mock-apis/**/*.mock.ts'],
// log: 'debug',
// build: {
// log: 'debug',
// serverPort: env.PORT ? Number(env.PORT) : undefined,
// },
// }),
],
// build: {
// manifest: '/public/manifest.json',
// },
test: {
globals: true,
environment: 'node',
transformMode: { web: [/.[tj]sx$/] },
setupFiles: './src/setupTests.ts',
coverage: {
reporter: ['text', 'json', 'html'],
include: ['src/**'],
exclude: ['src/shared/constants/**'],
},
server: {
debug: true,
},
},
server: {
port: env.PORT ? Number(env.PORT) : undefined,
host: env.HOST ?? undefined,
proxy: {
'/api': {
target: env.VITE_SERVER,
changeOrigin: true,
},
[`^/api/workspaces/[a-z0-9\\-]+/events`]: {
target: env.VITE_WS_SERVER,
changeOrigin: true,
ws: true,
},
},
},
preview: {
port: env.PORT ? Number(env.PORT) : undefined,
host: env.HOST ?? undefined,
proxy: {
'/api': {
target: env.VITE_SERVER,
changeOrigin: true,
},
[`^/api/workspaces/[a-z0-9\\-]+/events`]: {
target: env.VITE_WS_SERVER,
changeOrigin: true,
ws: true,
},
},
},
resolve: {
alias: [{ find: 'src', replacement: path.resolve(__dirname, 'src') }],
},
}
})