sokko-g/vite.config.js
Shinuwa 5ce35cd7ba Add the Sokko TCG collectible card mini-game
Add the server-backed card game: Discord login, recharging pack openings,
album, trades, gifts, stardust shop, campaign codes and its administration,
stored in SQLite and disabled in production until configured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 17:47:35 +01:00

40 lines
1.1 KiB
JavaScript

// Rôle : configure Vite et charge les variables locales communes au serveur.
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { loadProjectEnv } from "./scripts/load-project-env.mjs";
import { createCardsApiHandler } from "./services/cards/api.js";
import { resolve } from "node:path";
loadProjectEnv();
function nebulaCardsApi() {
return {
name: "nebula-cards-api",
apply: "serve",
configureServer(server) {
const handler = createCardsApiHandler({ projectRoot: resolve("."), enabled: process.env.CARDS_ENABLED !== "false", devAuth: process.env.CARDS_DEV_AUTH !== "false", devPerks: true });
server.middlewares.use(async (req, res, next) => {
if (!await handler(req, res)) next();
});
server.httpServer?.once("close", handler.close);
}
};
}
export default defineConfig({
root: "website",
publicDir: "public",
plugins: [react(), nebulaCardsApi()],
server: {
host: "0.0.0.0",
port: Number(process.env.PORT || 5173)
},
preview: {
host: "0.0.0.0",
port: Number(process.env.PORT || 4173)
},
build: {
outDir: "dist",
emptyOutDir: true
}
});