fix: replace require() with express.static import for ESM compat

This commit is contained in:
notshop 2026-04-26 17:17:39 +00:00
parent d9bad7d636
commit f13d623708

View file

@ -1,9 +1,11 @@
import { type Express } from "express";
import { createServer as createViteServer, createLogger } from "vite";
import { type Server } from "http";
import { createRequire } from "module";
import viteConfig from "../vite.config";
import fs from "fs";
import path from "path";
import express from "express";
const viteLogger = createLogger();
@ -48,7 +50,7 @@ export function serveStatic(app: Express) {
throw new Error(`Production build not found at ${distPath}. Run 'npm run build' first.`);
}
app.use(
require("express").static(distPath, {
express.static(distPath, {
maxAge: "1y",
index: false,
})