38 lines
864 B
TypeScript
38 lines
864 B
TypeScript
import react from "@vitejs/plugin-react";
|
|
import { defineConfig } from "vite";
|
|
import { handleSteamRefresh, handleConfigLoad } from "./server/steam-api.mjs";
|
|
import { handleGameAsset } from "./server/assets-api.mjs";
|
|
|
|
const apiMiddlewarePlugin = {
|
|
name: "api-middleware",
|
|
configureServer(server) {
|
|
server.middlewares.use((req, res, next) => {
|
|
const url = req.url ?? "";
|
|
if (url.startsWith("/api/steam/refresh")) {
|
|
return handleSteamRefresh(req, res);
|
|
}
|
|
if (url.startsWith("/api/config/load")) {
|
|
return handleConfigLoad(req, res);
|
|
}
|
|
if (url.startsWith("/api/games/")) {
|
|
return handleGameAsset(req, res);
|
|
}
|
|
next();
|
|
});
|
|
},
|
|
};
|
|
|
|
export default defineConfig({
|
|
base: "/whattoplay/",
|
|
plugins: [react(), apiMiddlewarePlugin],
|
|
server: {
|
|
port: 5173,
|
|
hmr: {
|
|
overlay: true,
|
|
},
|
|
watch: {
|
|
usePolling: true,
|
|
},
|
|
},
|
|
});
|