Replace the pure-JS lzma decoder with lzma-wasm (Rust/WASM, base64-inlined, zero-alloc decompress), giving an order-of-magnitude speedup on furni imports. Remove the obsolete lzma type shim and the redundant top-level vite dev dependency, which nothing imports directly.
163 lines
3.6 KiB
TypeScript
163 lines
3.6 KiB
TypeScript
import { execSync } from "node:child_process";
|
|
import type { NextConfig } from "next";
|
|
import createNextIntlPlugin from "next-intl/plugin";
|
|
|
|
const getGitCommit = () => {
|
|
try {
|
|
return execSync("git rev-parse HEAD", { encoding: "utf8" }).trim();
|
|
} catch {
|
|
return undefined;
|
|
}
|
|
};
|
|
|
|
const securityHeaders = [
|
|
{ key: "X-DNS-Prefetch-Control", value: "on" },
|
|
{
|
|
key: "Strict-Transport-Security",
|
|
value: "max-age=63072000; includeSubDomains; preload",
|
|
},
|
|
{ key: "X-Frame-Options", value: "DENY" },
|
|
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
|
{
|
|
key: "Permissions-Policy",
|
|
value: "camera=(), microphone=(), geolocation=(), interest-cohort=()",
|
|
},
|
|
];
|
|
|
|
const nextConfig: NextConfig = {
|
|
output: "standalone",
|
|
deploymentId: process.env.NEXT_DEPLOYMENT_ID?.trim() || getGitCommit(),
|
|
distDir: process.env.NEXT_DIST_DIR?.trim() || ".next",
|
|
reactStrictMode: true,
|
|
compress: true,
|
|
productionBrowserSourceMaps: false,
|
|
serverExternalPackages: ["lzma-wasm", "sharp", "pino", "pino-pretty"],
|
|
|
|
async redirects() {
|
|
return [
|
|
{
|
|
source: "/admin/import",
|
|
destination: "/admin/studio/furni",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/import/badges",
|
|
destination: "/admin/studio/badges",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/import/furni",
|
|
destination: "/admin/studio/furni",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/import/furni/upload",
|
|
destination: "/admin/studio/upload",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/import/clothing",
|
|
destination: "/admin/studio/clothing",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/import/effects",
|
|
destination: "/admin/studio/effects",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/import/pets",
|
|
destination: "/admin/studio/pets",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/import/clone",
|
|
destination: "/admin/studio/clone",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/import/sync",
|
|
destination: "/admin/studio/sync",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/import/repair-icons",
|
|
destination: "/admin/studio/repair-icons",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/admin/import/audit",
|
|
destination: "/admin/studio/audit",
|
|
permanent: true,
|
|
},
|
|
];
|
|
},
|
|
|
|
turbopack: {
|
|
ignoreIssue: [
|
|
{
|
|
path: "**/src/lib/**",
|
|
},
|
|
],
|
|
},
|
|
|
|
experimental: {
|
|
optimizePackageImports: ["lucide-react", "date-fns"],
|
|
useTypeScriptCli: true,
|
|
hideLogsAfterAbort: true,
|
|
},
|
|
|
|
images: {
|
|
formats: ["image/avif", "image/webp"],
|
|
},
|
|
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: "/(.*)",
|
|
headers: securityHeaders,
|
|
},
|
|
{
|
|
source: "/assets/(.*)",
|
|
headers: [
|
|
{
|
|
key: "Cache-Control",
|
|
value: "public, max-age=31536000, immutable",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
// Nitro client payload (~2.8GB across swf/nitro-assets): without
|
|
// caching every client open re-downloads hundreds of files.
|
|
// Fresh for 7 days, then serve stale + revalidate in background
|
|
// so asset updates still propagate without blocking players.
|
|
source: "/swf/(.*)",
|
|
headers: [
|
|
{
|
|
key: "Cache-Control",
|
|
value: "public, max-age=604800, stale-while-revalidate=2592000",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
source: "/nitro-assets/(.*)",
|
|
headers: [
|
|
{
|
|
key: "Cache-Control",
|
|
value: "public, max-age=604800, stale-while-revalidate=2592000",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
source: "/images/(.*)",
|
|
headers: [{ key: "Cache-Control", value: "public, max-age=86400" }],
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
const withNextIntl = createNextIntlPlugin("./src/i18n/request.ts");
|
|
|
|
export default withNextIntl(nextConfig);
|