-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.js
39 lines (35 loc) · 1.02 KB
/
vite.config.js
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
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
import { Server } from 'socket.io';
process.env.BROWSER = 'firefox';
const webSocketServerPlugin = {
name: 'sveltekit-socket-io',
configureServer(server) {
const io = new Server(server.httpServer);
console.log('SocketIO injected');
// server-side
io.on('connection', (socket) => {
socket.on('promptChange', ({ userId, prompt }) => {
io.emit('promptChange', { userId: userId, prompt: prompt });
});
socket.on('imageReady', ({ userId, imageUrl }) => {
io.emit('imageReady', { userId: userId, imageUrl: imageUrl });
});
socket.on('celebrate', ({ userId }) => {
io.emit('celebrate', userId);
});
socket.on('generate', ({ userId }) => {
io.emit('generate', userId);
});
socket.on('reset', ({ userId }) => {
io.emit('reset', userId);
});
});
}
};
export default defineConfig({
plugins: [sveltekit(), webSocketServerPlugin],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
}
});