M1_ProjetWeb/vite.config.ts

22 lines
491 B
TypeScript
Raw Normal View History

2024-11-25 16:27:31 +01:00
import { sveltekit } from '@sveltejs/kit/vite';
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({
plugins: [sveltekit(), webSocketServer]
2024-11-25 16:27:31 +01:00
});