Merge pull request #4 from Jeff-Emmett/new-website

backend vite setup
This commit is contained in:
Jeff Emmett 2025-06-19 12:25:34 +02:00 committed by GitHub
commit 79a004ea9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 1373 additions and 1462 deletions

View File

@ -1,3 +1,4 @@
import React from "react";
import { Switch, Route } from "wouter";
import { queryClient } from "./lib/queryClient";
import { QueryClientProvider } from "@tanstack/react-query";

View File

@ -2,12 +2,17 @@ import { ClassCard } from "./class-card";
import { useQuery } from "@tanstack/react-query";
import { Class } from "@/lib/schema";
import { Skeleton } from "@/components/ui/skeleton";
import { apiRequest } from "@/lib/queryClient";
import FadiaClassImage from "../../assets/Fadia-156.jpg";
export function ClassesSection() {
const { data: classes, isLoading, error } = useQuery<Class[]>({
queryKey: ["/api/classes"],
queryFn: async () => {
const res = await apiRequest("GET", "/api/classes");
return await res.json();
},
});
return (

View File

@ -51,11 +51,11 @@
@layer base {
* {
@apply border-border;
@apply border-gray-200;
}
body {
@apply font-sans antialiased bg-background text-foreground;
@apply font-sans antialiased bg-white text-gray-900;
font-family: 'Khula', sans-serif;
}

View File

@ -44,11 +44,11 @@ export const getQueryFn: <T>(options: {
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
queryFn: getQueryFn({ on401: "throw" }),
retry: false,
refetchInterval: false,
refetchOnWindowFocus: false,
staleTime: Infinity,
retry: false,
gcTime: 5 * 60 * 1000, // 5 minutes
},
mutations: {
retry: false,

View File

@ -1,3 +1,4 @@
import React from "react";
import { createRoot } from "react-dom/client";
import App from "./App";
import "./index.css";

View File

@ -1,8 +1,12 @@
import type { Config } from "tailwindcss";
import path from "path";
export default {
darkMode: ["class"],
content: ["./client/index.html", "./client/src/**/*.{js,jsx,ts,tsx}"],
content: [
path.resolve(__dirname, "index.html"),
path.resolve(__dirname, "src/**/*.{js,jsx,ts,tsx}")
],
theme: {
extend: {
borderRadius: {
@ -92,5 +96,5 @@ export default {
},
},
},
plugins: [require("tailwindcss-animate"), require("@tailwindcss/typography")],
plugins: [require("tailwindcss-animate")],
} satisfies Config;

20
client/vite.config.ts Normal file
View File

@ -0,0 +1,20 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig({
plugins: [
react(),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
"@shared": path.resolve(__dirname, "../shared"),
"@assets": path.resolve(__dirname, "../attached_assets"),
},
},
build: {
outDir: "dist",
emptyOutDir: true,
},
});

2740
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,8 @@
"license": "MIT",
"scripts": {
"dev": "NODE_ENV=development tsx server/index.ts",
"build": "npm run build:client",
"build:client": "cd client && vite build",
"build": "cd client && npm install && npm run build",
"build:client": "cd client && npm run build",
"build:server": "esbuild server/index.ts --platform=node --packages=external --bundle --format=esm --outdir=dist",
"start": "NODE_ENV=production node dist/index.js",
"check": "tsc"

View File

@ -3,7 +3,6 @@ import fs from "fs";
import path from "path";
import { createServer as createViteServer, createLogger } from "vite";
import { type Server } from "http";
import viteConfig from "../vite.config";
import { nanoid } from "nanoid";
const viteLogger = createLogger();
@ -20,15 +19,23 @@ export function log(message: string, source = "express") {
}
export async function setupVite(app: Express, server: Server) {
const serverOptions = {
middlewareMode: true,
hmr: { server },
allowedHosts: true as true,
};
const vite = await createViteServer({
...viteConfig,
configFile: false,
root: path.resolve(import.meta.dirname, "..", "client"),
resolve: {
alias: {
"@": path.resolve(import.meta.dirname, "..", "client", "src"),
"@shared": path.resolve(import.meta.dirname, "..", "shared"),
"@assets": path.resolve(import.meta.dirname, "..", "attached_assets"),
},
},
server: {
hmr: false,
middlewareMode: true
},
optimizeDeps: {
exclude: ['@vite/client']
},
customLogger: {
...viteLogger,
error: (msg, options) => {
@ -36,7 +43,6 @@ export async function setupVite(app: Express, server: Server) {
process.exit(1);
},
},
server: serverOptions,
appType: "custom",
});

View File

@ -1,6 +1,7 @@
{
"version": 2,
"buildCommand": "npm run build",
"buildCommand": "cd client && npm install && npm run build",
"outputDirectory": "client/dist",
"builds": [
{
"src": "server/index.ts",

View File

@ -1,21 +0,0 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig({
plugins: [
react(),
],
resolve: {
alias: {
"@": path.resolve(import.meta.dirname, "client", "src"),
"@shared": path.resolve(import.meta.dirname, "shared"),
"@assets": path.resolve(import.meta.dirname, "attached_assets"),
},
},
root: path.resolve(import.meta.dirname, "client"),
build: {
outDir: path.resolve(import.meta.dirname, "client", "dist"),
emptyOutDir: true,
},
});