🐛 Fix deploy base_url

main
Shad Amethyst 10 months ago
parent 869f1ea283
commit 5932f9cd06

@ -4,3 +4,4 @@ PUBLIC_LOBBY_SERVER="http://localhost:3200/"
SOCKETIO_PORT=3100
LOBBY_PORT=3200
BASE="/"

2
.gitignore vendored

@ -2,3 +2,5 @@
node_modules/
src/env.d.ts
dist/
*.js
.turbo/

@ -2,9 +2,13 @@ import { fileURLToPath } from "url";
import { defineConfig } from "astro/config";
import solidJs from "@astrojs/solid-js";
import node from "@astrojs/node";
import dotenv from "dotenv";
dotenv.config();
export default defineConfig({
site: import.meta.env.PUBLIC_BASE_URL ?? "http://localhost:3000/",
site: process.PUBLIC_BASE_URL ?? "http://localhost:3000/",
base: process.env.ASTRO_BASE,
integrations: [solidJs()],
outDir: fileURLToPath(new URL("./dist/", import.meta.url)),
output: "server",

@ -0,0 +1,10 @@
#!/bin/sh
yarn run esbuild ./index.ts \
--bundle \
--platform=node \
--outfile=./index.js \
--packages=external \
--format=esm \
--alias:boardgame.io/server=boardgame.io/dist/cjs/server.js \
--alias:boardgame.io/core=boardgame.io/dist/cjs/core.js

@ -11,7 +11,7 @@ export async function startServer() {
origins: [Origins.LOCALHOST],
});
const env = dotenv.parse(await fs.readFile(new URL(".env", import.meta.url)));
const env = dotenv.parse(await fs.readFile(new URL(".env", import.meta.url)).catch(() => ""));
server.run({
port: +(env["SOCKETIO_PORT"] ?? 3100),
lobbyConfig: {
@ -25,6 +25,7 @@ export async function registerFastify(app: import("fastify").FastifyInstance, pr
app.register(fastifyStatic, {
root: fileURLToPath(new URL(`./dist/client`, import.meta.url)),
prefix: prefix,
decorateReply: false,
});
// @ts-ignore

@ -10,7 +10,7 @@
"dev": "astro dev",
"server": "bun ./server.ts",
"lint": "astro check && tsc --noEmit",
"build": "astro build"
"build": "astro build && ./build-index.sh"
},
"dependencies": {
"@astrojs/node": "^5.1.2",
@ -19,6 +19,7 @@
"astro": "^2.3.3",
"boardgame.io": "^0.50.2",
"dotenv": "^16.3.1",
"esbuild": "^0.18.14",
"sass": "^1.62.1",
"solid-js": "^1.7.8"
},

@ -1,4 +1,4 @@
import { PLAYER_COLORS } from "../consts.js";
import { BASE_URL, PLAYER_COLORS } from "../consts.js";
import classes from "./Toolbar.module.css";
import PlayerTile from "../tile-player-any.svg?raw";
import { Building, Buildings, PlaceableBuildings } from "../game.js";
@ -98,7 +98,7 @@ function ToolbarItem(props: {
></div>
{
props.type !== "road" &&
<img class={classes.icon} src={`/tile-${props.type}.svg`} width={WIDTH} height={HEIGHT} />
<img class={classes.icon} src={`${BASE_URL}/tile-${props.type}.svg`} width={WIDTH} height={HEIGHT} />
}
</li>;
}

Loading…
Cancel
Save