-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
70 lines (62 loc) · 1.94 KB
/
vite.config.ts
File metadata and controls
70 lines (62 loc) · 1.94 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
import { defineConfig, PluginOption, ViteDevServer } from 'vite';
import react from '@vitejs/plugin-react-swc';
import tailwindcss from '@tailwindcss/vite';
import basicSsl from '@vitejs/plugin-basic-ssl';
import dotenv from 'dotenv';
import packageJson from './package.json';
import { mockServer } from './cloud-function-mocks/mock-server';
// define a mock express server to handle cloud function requests,
// and configure it as a vite server middleware plugin
const mockServerPlugin = () => {
return {
name: 'mock-cloud-functions',
configureServer(server: ViteDevServer) {
server.middlewares.use(mockServer);
},
};
}
const plugins: PluginOption[] = [
react(),
tailwindcss(),
mockServerPlugin()
];
const define: Record<string, string> = {
'import.meta.env.PACKAGE_VERSION': JSON.stringify(packageJson.version),
};
if (process.argv?.includes('--ssl')) {
plugins.push(basicSsl());
const dotEnvVars: { [varKey: string]: string} = {};
dotenv.config({ processEnv: dotEnvVars, path: ['.env.development'] });
define['import.meta.env.TST_OAUTH_GOOGLE_REDIRECT_ORIGIN'] = JSON.stringify(dotEnvVars.TST_OAUTH_GOOGLE_REDIRECT_ORIGIN.replace('http', 'https'));
console.log('🔐 Local SSL Enabled');
}
export default defineConfig({
resolve: {
alias: {
'cloud-functions': '/cloud-functions',
'data': '/src/shared/data',
'components': '/src/shared/components',
'context': '/src/context',
'pages': '/src/pages',
},
},
plugins,
server: {
// these routes will be handled by mockServerPlugin, but we define them here in the proxy config
// to ensure they aren't handled by vite as a default route that returns the SPA
proxy: {
'/oauth-exchange': {},
'/oauth-refresh': {},
'/oauth-revoke': {},
'/admin-sess': {},
'/admin-expire-sess': {}
},
watch: {
ignored: [
'**/mock-session-store.json'
],
},
},
define,
envPrefix: 'TST_'
});