generated from cfpb/open-source-project-template
/
vite.config.ts
118 lines (113 loc) · 3.27 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
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
111
112
113
114
115
116
117
118
/* eslint-disable */
/// <reference types="vitest" />
import eslintPlugin from '@nabla/vite-plugin-eslint';
import react from '@vitejs/plugin-react';
import { defineConfig, loadEnv } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
import tsconfigPaths from 'vite-tsconfig-paths';
import svgr from 'vite-plugin-svgr';
export default async ({ mode }) => {
// NOTE: This is used to load environment variables from ".env" into "process.env" to be used in "vite.config.ts"
// process.env = {...process.env, ...loadEnv(mode, process.cwd())};
// import.meta.env.VITE_NAME available here with: process.env.VITE_NAME
// import.meta.env.VITE_PORT available here with: process.env.VITE_PORT
/* Includes both process.env and .env variables */
const environment = loadEnv(mode, process.cwd(), '');
return defineConfig({
optimizeDeps: {
exclude: [],
},
resolve: {
dedupe: ['react-router-dom'],
},
test: {
css: false,
include: ['src/**/__tests__/*'],
globals: true,
environment: 'jsdom',
setupFiles: 'src/setupTests.ts',
clearMocks: true,
coverage: {
provider: 'istanbul',
enabled: true,
'100': true,
reporter: ['text', 'lcov'],
reportsDirectory: 'coverage',
},
},
server: {
watch: {
usePolling: true,
},
host: true,
strictPort: true,
port: Boolean(Number(environment.SBL_DEV_PORT))
? Number(environment.SBL_DEV_PORT)
: 8899,
proxy: {
// NOTE: Add Proxy settings to api calls on the backend here
"/v1/admin": {
target: `${environment.SBL_REGTECH_BASE_URL}`,
changeOrigin: true,
secure: false,
},
"/v1/institutions": {
target: `${environment.SBL_REGTECH_BASE_URL}`,
changeOrigin: true,
secure: false,
},
"/v1/filing": {
target: `${environment.SBL_FILING_BASE_URL}`,
changeOrigin: true,
secure: false,
},
"/send": {
target: `${environment.SBL_MAIL_BASE_URL}`,
changeOrigin: true,
secure: false,
},
// "/ssr": {
// target: "http://localhost:33160",
// changeOrigin: true,
// secure: false,
},
},
plugins: [
svgr(),
tsconfigPaths(),
react(),
...(mode === 'test'
? []
: [
eslintPlugin(),
VitePWA({
registerType: 'autoUpdate',
includeAssets: [
'icons8-usa-96',
'favicon.png',
'robots.txt',
'apple-touch-icon.png',
'icons/*.svg',
],
manifest: {
theme_color: '#BD34FE',
icons: [
{
src: '/android-chrome-192x192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any maskable',
},
{
src: '/android-chrome-512x512.png',
sizes: '512x512',
type: 'image/png',
},
],
},
}),
]),
],
envPrefix: 'SBL_',
});
};