Files
restitution/webpack.config.js
kaykayyali 3fc29f728e feat: Colyseus authoritative server + invite-code lobby
- Replace socket.io relay with Colyseus 0.15 authoritative server
- GameRoom with GameState schema (players, units, resources)
- Pure TS services: CombatResolver, EconomyService, PathfindingService, UnitManager
- POST /api/create-room → 4-char invite code
- React/MUI LobbyScreen: Create (shows code + START GAME) / Join by code
- ColyseusClient: joinOrCreate/join by room type = invite code
- Nginx: static assets direct, all else proxied to Colyseus (WS upgrade)
- Content-hashed JS bundles for Cloudflare cache-busting
- 1-player lobbies: START GAME button bypasses 2-player wait
2026-05-30 02:49:20 +00:00

90 lines
1.9 KiB
JavaScript

const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
mode: "development",
entry: {
index: "./src/index.js",
},
resolve: {
alias: {
PhaserClasses: path.resolve(__dirname, "src/phaserClasses/"),
Components: path.resolve(__dirname, "src/components/"),
Entities: path.resolve(__dirname, "src/entities/"),
Scenes: path.resolve(__dirname, "src/scenes/"),
Scripts: path.resolve(__dirname, "src/scripts/"),
Styles: path.resolve(__dirname, "src/styles/"),
Systems: path.resolve(__dirname, "src/systems/"),
},
},
devtool: "inline-source-map",
devServer: {
static: "./public",
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "OPTIONS, POST, GET",
},
},
plugins: [
new HtmlWebpackPlugin({
title: "Game Server",
meta: {
language: {
httpEquiv: "Content-Language",
content: "en_US",
},
viewport: {
key: "viewport",
content: "initial-scale=1, width=device-width",
},
},
templateContent: ({ htmlWebpackPlugin }) => `
<html>
<head>
${htmlWebpackPlugin.tags.headTags}
<title>Restitution</title>
</head>
<body>
<div id="root"></div>
${htmlWebpackPlugin.tags.bodyTags}
</body>
</html>
`,
}),
],
output: {
filename: "[name].[contenthash].js",
path: path.resolve(__dirname, "dist"),
clean: true,
},
optimization: {
runtimeChunk: "single",
},
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"],
},
},
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: "asset/resource",
},
],
},
};