-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.ts
58 lines (54 loc) · 1.45 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
57
58
/// <reference types="vitest" />
import { Config } from '@fullstacksjs/config';
import { compact } from '@fullstacksjs/toolbox';
import basicSsl from '@vitejs/plugin-basic-ssl';
import react from '@vitejs/plugin-react';
import type { UserConfig } from 'vite';
import { defineConfig } from 'vite';
import checker from 'vite-plugin-checker';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';
import { cypressAliases } from './configs/vite/cypressAliases';
const envs = new Config({
port: Config.number({ default: 3000 }),
host: Config.string(),
target: Config.string(),
open: Config.boolean(),
}).parse({
port: process.env.PORT,
host: process.env.HOST,
target: process.env.TARGET,
open: process.env.OPEN,
});
interface Options {
https?: boolean;
}
export const config = ({ https = true }: Options = {}): UserConfig => ({
plugins: compact([
https ? basicSsl() : undefined,
checker({ typescript: true }),
tsconfigPaths(),
cypressAliases(),
react({ exclude: /\.stories\.(t|j)sx?$/ }),
svgr(),
]),
server: {
port: envs.get('port'),
host: envs.get('host'),
open: envs.get('open'),
strictPort: true,
proxy: {
'/graphql': {
target: envs.get('target'),
changeOrigin: true,
},
},
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./configs/vitest/setup.ts'],
},
envPrefix: 'APP',
});
export default defineConfig(config());