2024-11-25 16:27:31 +01:00
|
|
|
import { sveltekit } from '@sveltejs/kit/vite';
|
2024-12-01 22:27:49 +01:00
|
|
|
import { type ViteDevServer, defineConfig } from 'vite';
|
|
|
|
|
|
|
|
import { Server } from 'socket.io'
|
|
|
|
|
|
|
|
const webSocketServer = {
|
|
|
|
name: 'webSocketServer',
|
|
|
|
configureServer(server: ViteDevServer) {
|
|
|
|
if (!server.httpServer) return
|
|
|
|
|
|
|
|
const io = new Server(server.httpServer)
|
|
|
|
|
|
|
|
io.on('connection', (socket) => {
|
|
|
|
socket.emit('eventFromServer', 'Hello, World 👋')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2024-11-25 16:27:31 +01:00
|
|
|
|
|
|
|
export default defineConfig({
|
2024-12-01 22:27:49 +01:00
|
|
|
plugins: [sveltekit(), webSocketServer]
|
2024-11-25 16:27:31 +01:00
|
|
|
});
|