fix: replace require() with express.static import for ESM compat
This commit is contained in:
parent
d9bad7d636
commit
f13d623708
1 changed files with 3 additions and 1 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
import { type Express } from "express";
|
import { type Express } from "express";
|
||||||
import { createServer as createViteServer, createLogger } from "vite";
|
import { createServer as createViteServer, createLogger } from "vite";
|
||||||
import { type Server } from "http";
|
import { type Server } from "http";
|
||||||
|
import { createRequire } from "module";
|
||||||
import viteConfig from "../vite.config";
|
import viteConfig from "../vite.config";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import express from "express";
|
||||||
|
|
||||||
const viteLogger = createLogger();
|
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.`);
|
throw new Error(`Production build not found at ${distPath}. Run 'npm run build' first.`);
|
||||||
}
|
}
|
||||||
app.use(
|
app.use(
|
||||||
require("express").static(distPath, {
|
express.static(distPath, {
|
||||||
maxAge: "1y",
|
maxAge: "1y",
|
||||||
index: false,
|
index: false,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue