mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-15 04:12:34 -06:00
refactor(web): migrate frontend to Tailwind CSS and Vike SSR
- Replace Mantine UI components with Tailwind CSS v4 - Migrate from static HTML to Vike-based SSR framework - Disable SSR for game page (Emscripten requires browser environment) - Simplify Emscripten loading to avoid hydration conflicts - Remove Tailwind download logic from web.build.ts - Add package manager lockfiles for reproducible builds - Update .gitignore for node_modules and build artifacts
This commit is contained in:
@@ -1,16 +1,45 @@
|
||||
import { AspectRatio } from "@mantine/core";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function Page() {
|
||||
useEffect(() => {
|
||||
// Only setup Module if not already configured (prevents double-initialization on hot reload)
|
||||
if (!(window as any).Module) {
|
||||
const canvas = document.getElementById("canvas");
|
||||
|
||||
// Simple Module configuration matching the original working approach
|
||||
(window as any).Module = {
|
||||
canvas: canvas,
|
||||
locateFile: (path: string) => {
|
||||
// Return absolute paths for all resources
|
||||
return path.startsWith("/") ? path : `/${path}`;
|
||||
},
|
||||
preRun: [],
|
||||
};
|
||||
|
||||
// Load the Emscripten script
|
||||
const script = document.createElement("script");
|
||||
script.src = "/pacman.js";
|
||||
script.async = false; // Load synchronously to ensure Module is configured first
|
||||
document.body.appendChild(script);
|
||||
|
||||
// Cleanup function (runs when component unmounts)
|
||||
return () => {
|
||||
script.remove();
|
||||
};
|
||||
}
|
||||
}, []); // Empty dependency array = run once on mount
|
||||
|
||||
return (
|
||||
<div className="mt-4 flex justify-center h-[calc(100vh-120px)]">
|
||||
<AspectRatio ratio={1.0 / 1.2} w="min(100vh * 1.2, 100vw)" maw="95vw">
|
||||
<canvas
|
||||
className="block border-1 border-yellow-400/50 w-full h-full"
|
||||
style={{
|
||||
boxShadow: "0 0 12px rgba(250, 204, 21, 0.35), 0 0 2px rgba(255, 255, 255, 0.25)",
|
||||
}}
|
||||
/>
|
||||
</AspectRatio>
|
||||
<div
|
||||
className="block border-1 border-yellow-400/50 aspect-[5/6] h-[min(calc(100vh-120px),_calc(95vw_*_6/5))] w-auto"
|
||||
style={{
|
||||
boxShadow:
|
||||
"0 0 12px rgba(250, 204, 21, 0.35), 0 0 2px rgba(255, 255, 255, 0.25)",
|
||||
}}
|
||||
>
|
||||
<canvas id="canvas" className="w-full h-full" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
7
web/pages/index/+config.ts
Normal file
7
web/pages/index/+config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { Config } from "vike/types";
|
||||
|
||||
// Disable SSR for the game page since Emscripten requires a browser environment
|
||||
export default {
|
||||
prerender: false, // Don't pre-render during build
|
||||
ssr: false, // Force client-side only rendering
|
||||
} satisfies Config;
|
||||
Reference in New Issue
Block a user