-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
37 lines (33 loc) · 1.06 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
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import type { IncomingMessage, ServerResponse } from 'http';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
const env = loadEnv(mode, process.cwd(), '');
return {
base: env.VITE_BASE_URL || '/',
plugins: [
react(),
{
name: 'wms-middleware',
async configureServer(server) {
const express = (await import('express')).default;
const { handleWmsRequest } = await import('./server/middleware/wms');
server.middlewares.use(express.json());
// Add WMS endpoint
server.middlewares.use('/wms/handle', (req: IncomingMessage, res: ServerResponse, next) => {
if (req.method === 'POST') {
handleWmsRequest(req, res);
} else {
next();
}
});
},
},
],
optimizeDeps: {
exclude: ['lucide-react'],
},
};
});