-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
74 lines (66 loc) · 1.91 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
/**
* Vite Configuration File (vite.config.ts)
*
* This file configures the Vite build tool for the project.
* It includes settings for plugins, server proxy, path resolution,
* and other build optimizations.
*
* For more information on Vite and its configuration options, visit:
* https://vitejs.dev/config/
*/
// Import required plugins and modules
import react from '@vitejs/plugin-react';
// import basicSsl from '@vitejs/plugin-basic-ssl';
import { config } from 'dotenv';
import path from 'path';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
// Load environment variables from .env file
config();
// Export Vite configuration object
export default defineConfig({
// Add plugins to Vite
plugins: [
// Enable React plugin for handling React components
react(),
// Resolve TypeScript path aliases based on tsconfig.json
tsconfigPaths(),
// basicSsl({
// /** name of certification */
// name: 'test',
// /** custom trust domains */
// domains: ['*.custom.com'],
// /** custom certification directory */
// certDir: '/Users/.../.devServer/cert',
// }),
],
server: {
// Configure development server proxy
proxy: {
'/api': {
// Set target URL for API calls
target: process.env.VITE_PROXY_URL || 'http://localhost:4000',
// Enable changing the request's origin
changeOrigin: true,
// Rewrite the path, removing '/api' from the beginning
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
resolve: {
alias: {
// Define custom alias for the 'src' directory
'@': path.resolve(__dirname, './src'),
},
},
optimizeDeps: {
esbuildOptions: {
// Define global variable mapping
define: {
global: 'globalThis',
},
// Add any esbuild plugins if required (currently empty)
plugins: [],
},
},
});