-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
43 lines (39 loc) · 1.07 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
import { defineConfig, createServer, PluginOption } from 'vite'
import createOtherAppViteConfig from './other-app/create-vite-config'
const port = 9616
function addOtherApp(): PluginOption {
return {
name: 'vite-plugin-add-other-app',
async configureServer(viteDevServer) {
const otherAppConfig = createOtherAppViteConfig()
const extendedOtherAppConfig = {
...otherAppConfig,
base: '/anotherApp',
server: {
...(otherAppConfig.server || {}),
middlewareMode: {
server: viteDevServer.httpServer,
},
hmr: {
port,
server: viteDevServer.httpServer,
},
},
}
const otherAppServer = await createServer(extendedOtherAppConfig)
viteDevServer.httpServer.on('close', () => {
otherAppServer.close()
})
viteDevServer.middlewares.use('/anotherApp', otherAppServer.middlewares)
},
}
}
export default defineConfig(() => {
return {
server: {
port,
strictPort: true,
},
plugins: [addOtherApp()],
}
})