-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathvite.config.ts
More file actions
110 lines (104 loc) · 2.7 KB
/
Copy pathvite.config.ts
File metadata and controls
110 lines (104 loc) · 2.7 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import react from '@vitejs/plugin-react';
import autoprefixer from 'autoprefixer';
import path from 'path';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import EnvironmentPlugin from 'vite-plugin-environment';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), EnvironmentPlugin('all')],
resolve: {
tsconfigPaths: true,
alias: {
'~uswds': path.resolve(__dirname, 'node_modules/@uswds/uswds'),
},
},
css: {
preprocessorOptions: {
scss: {
loadPaths: ['node_modules/@uswds/uswds/packages'],
// Silence warnings coming from USWDS SCSS
quietDeps: true,
logger: {
warn: (msg: string) => {
if (msg.includes('legacy-js-api')) {
return;
}
// eslint-disable-next-line no-console
console.warn(msg);
},
},
},
},
postcss: {
plugins: [autoprefixer],
},
},
server: {
open: true,
port: 5173,
proxy: {
// Provides mocked signin for local development
'/api/auth/signin': {
target: 'http://0.0.0.0:8000',
bypass: (req, res) => {
if (!res) return;
res.setHeader('Content-Type', 'application/json');
let data = '';
req.on('data', (chunk) => {
data += chunk;
});
req.on('end', () => {
const validUses = ['admin', 'test'];
const body = JSON.parse(data);
const username = body.username;
if (!validUses.includes(username)) {
return;
}
res.end(
JSON.stringify({
first_name: 'Test',
last_name: 'User',
}),
);
});
return;
},
},
'/api': {
target: 'http://0.0.0.0:8000',
rewrite: (path) => path.replace(/^\/api/, ''),
changeOrigin: true,
},
},
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: './vitest.setup.ts',
exclude: ['node_modules/**', 'e2e/**'],
coverage: {
all: false,
provider: 'v8',
thresholds: {
global: {
statements: 95,
branches: 95,
functions: 95,
lines: 95,
},
},
exclude: ['src/utils/axios.ts', 'src/utils/keycloak.ts'],
},
css: false,
alias: {
// This is necessary to prevent cjs/esm conflicts
'@metrostar/comet-uswds': path.resolve(
__dirname,
'node_modules/@metrostar/comet-uswds/dist/esm/index.js',
),
},
},
});