Skip to content

Commit

Permalink
use socket.io only in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ruucm committed Sep 9, 2024
1 parent 7b66491 commit 249a403
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import fs from "fs";
import path from "path";
import { Server as SocketIO } from "socket.io";

// Create socket server
const socketServer = http.createServer();
const io = new SocketIO(socketServer, {
cors: {
origin: "*",
credentials: true,
methods: ["GET", "POST", "OPTIONS", "PUT", "PATCH", "DELETE", "HEAD"],
},
});
socketServer.listen(8001, "0.0.0.0");

export default defineConfig((options): any => {
const isDev = options.watch;
let io: SocketIO | null = null;

if (isDev) {
// Create socket server
const socketServer = http.createServer();
io = new SocketIO(socketServer, {
cors: {
origin: "*",
credentials: true,
methods: ["GET", "POST", "OPTIONS", "PUT", "PATCH", "DELETE", "HEAD"],
},
});
socketServer.listen(8001, "0.0.0.0");
}

return {
entry: [
Expand Down

0 comments on commit 249a403

Please sign in to comment.