The leaderboard started in this repository because when it was written there was one game. It was already being treated as shared -- games.jcoffey.dev calls it "the shared leaderboard" in its compose file and nginx proxies it at a site-wide /api/ rather than under /lemonade/ -- but it was still this game's code, and the second game would have meant a second container, a second volume and a second database to back up for every game after that. It lives in https://github.com/Coffey-Labs/games-scores now, which is its own repository rather than either game's. A shared board belongs to no game, and leaving it here would have made every future game depend on the lemonade stand for its leaderboard. What changes here is smaller than the diff suggests. server/ goes, and with it scripts/dev-all.mjs and two package scripts. The client names the game on every call and is otherwise untouched: rows still come back as assets, days, glasses and broke, because the shared service hands each game its own field names back. Nothing about the deployed board moves. The volume keeps its name, the rows are migrated in place on first boot, and the original table is kept alongside as scores_lemonade_v1 rather than dropped -- it is the only copy of a board real people are on. Bundles already in browsers keep working too: a post with no game at all is treated as this one, deliberately, until this build has been out long enough that nobody is running the old one. Build clean.
23 lines
783 B
TypeScript
23 lines
783 B
TypeScript
import react from '@vitejs/plugin-react'
|
|
import { defineConfig } from 'vite'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
// Asset URLs are baked in at build time, so this has to match the path the
|
|
// game is served from. Local development stays at the root.
|
|
base: process.env.BASE_PATH ?? '/',
|
|
plugins: [react()],
|
|
server: {
|
|
// The game talks to /api in every environment; in production that is
|
|
// nginx in front of the shared scores container. In development, run
|
|
// https://github.com/Coffey-Labs/games-scores alongside this -- or do not,
|
|
// and the board will say so rather than breaking.
|
|
proxy: {
|
|
'/api': {
|
|
target: process.env.SCORES_TARGET ?? 'http://localhost:5184',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
})
|