mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
npm run build && npm start works (not npm run dev)
This commit is contained in:
parent
05a0d422d2
commit
6ec0fba38a
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,3 +4,4 @@ node_modules
|
|||
/.cache
|
||||
/server/build
|
||||
/public/build
|
||||
/build
|
||||
|
|
@ -1,38 +1,12 @@
|
|||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import z from "zod";
|
||||
import { weapons } from "~/constants";
|
||||
import type {
|
||||
LookingLoaderData,
|
||||
LookingLoaderDataGroup,
|
||||
} from "~/routes/play/looking";
|
||||
import rawInfos from "./data.json";
|
||||
|
||||
const infos = z
|
||||
.record(
|
||||
z.object({
|
||||
weapons: z.array(z.enum(weapons)).optional(),
|
||||
peakXP: z.number().optional(),
|
||||
peakLP: z.number().optional(),
|
||||
})
|
||||
)
|
||||
.parse(
|
||||
JSON.parse(
|
||||
fs
|
||||
.readFileSync(
|
||||
path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"..",
|
||||
"app",
|
||||
"core",
|
||||
"play",
|
||||
"playerInfos",
|
||||
"data.json"
|
||||
)
|
||||
)
|
||||
.toString()
|
||||
)
|
||||
);
|
||||
const infos = rawInfos as Partial<
|
||||
Record<string, { weapons?: string[]; peakXP?: number; peakLP?: number }>
|
||||
>;
|
||||
|
||||
export function addInfoFromOldSendouInk(
|
||||
type: "LEAGUE" | "SOLO",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
"dev": "concurrently \"npm run dev:remix\" \"npm run dev:server\"",
|
||||
"postinstall": "remix setup node",
|
||||
"gen": "npx prisma generate",
|
||||
"start": "cross-env NODE_ENV=production node ./server/build/index.js",
|
||||
"start": "cross-env NODE_ENV=production node ./build/index.js",
|
||||
"migration:create": "npx prisma migrate dev --create-only",
|
||||
"migration:apply:dev": "npx prisma migrate dev",
|
||||
"migration:apply:prod": "npx prisma migrate deploy",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
/**
|
||||
* @type {import('@remix-run/dev/config').AppConfig}
|
||||
* @type {import('@remix-run/dev').AppConfig}
|
||||
*/
|
||||
module.exports = {
|
||||
appDirectory: "app",
|
||||
browserBuildDirectory: "public/build",
|
||||
publicPath: "/build/",
|
||||
serverBuildDirectory: "server/build",
|
||||
devServerPort: 8002,
|
||||
server: "./server/index.js",
|
||||
devServerBroadcastDelay: 1000,
|
||||
//ignoredRouteFiles: [".*"],
|
||||
// appDirectory: "app",
|
||||
// assetsBuildDirectory: "public/build",
|
||||
// serverBuildPath: "build/index.js",
|
||||
// publicPath: "/build/",
|
||||
// devServerPort: 8002
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,18 +12,30 @@ import { EventTargetRecorder, setUpEvents } from "./events";
|
|||
import { setUpMockAuth } from "./mock-auth";
|
||||
import { setUpSeed } from "./seed";
|
||||
|
||||
const MODE = process.env.NODE_ENV;
|
||||
const BUILD_DIR = path.join(process.cwd(), "server/build");
|
||||
import * as build from "@remix-run/dev/server-build";
|
||||
|
||||
const PUBLIC_DIR = path.join(process.cwd(), "public");
|
||||
const BROWSER_BUILD_DIR = "/build/";
|
||||
|
||||
const app = express();
|
||||
app.disable("x-powered-by");
|
||||
app.use(compression());
|
||||
|
||||
// You may want to be more aggressive with this caching
|
||||
app.use(express.static("public", { maxAge: "1h" }));
|
||||
|
||||
// Remix fingerprints its assets so we can cache forever
|
||||
app.use(express.static("public/build", { immutable: true, maxAge: "1y" }));
|
||||
app.use(
|
||||
express.static("public", {
|
||||
setHeaders(res, pathname) {
|
||||
const relativePath = pathname.replace(PUBLIC_DIR, "");
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
relativePath.startsWith(BROWSER_BUILD_DIR)
|
||||
? // Remix fingerprints its assets so we can cache forever
|
||||
"public, max-age=31536000, immutable"
|
||||
: // You may want to be more aggressive with this caching
|
||||
"public, max-age=3600"
|
||||
);
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
app.use(morgan("tiny"));
|
||||
|
||||
|
|
@ -66,37 +78,10 @@ function getLoadContext(req: Express.Request) {
|
|||
|
||||
app.all(
|
||||
"*",
|
||||
MODE === "production"
|
||||
? createRequestHandler({
|
||||
build: require("./build"),
|
||||
getLoadContext,
|
||||
})
|
||||
: (req, res, next) => {
|
||||
purgeRequireCache();
|
||||
const build = require("./build");
|
||||
return createRequestHandler({
|
||||
build,
|
||||
mode: MODE,
|
||||
getLoadContext,
|
||||
})(req, res, next);
|
||||
}
|
||||
createRequestHandler({ build, mode: process.env.NODE_ENV, getLoadContext })
|
||||
);
|
||||
|
||||
const port = process.env.PORT ?? 5800;
|
||||
app.listen(port, () => {
|
||||
console.log(`Express server listening on port ${port}`);
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
function purgeRequireCache() {
|
||||
// purge require cache on requests for "server side HMR" this won't let
|
||||
// you have in-memory objects between requests in development,
|
||||
// alternatively you can set up nodemon/pm2-dev to restart the server on
|
||||
// file changes, we prefer the DX of this though, so we've included it
|
||||
// for you by default
|
||||
for (const key in require.cache) {
|
||||
if (key.startsWith(BUILD_DIR)) {
|
||||
delete require.cache[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user