Files
2026-03-24 05:13:49 -05:00

105 lines
2.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { getBuildProfile } = require("./scripts/build-resource-profile.cjs");
/** @type {import('next').NextConfig} */
const nextConfig = {
// Docker 部署支持
// output: 'standalone',
// 生产构建parallelism 由 scripts/next-build.cjs 注入 NAVSPHERE_WEBPACK_PARALLELISM直接 next build 则按机器自动算
webpack: (config, { dev }) => {
if (!dev) {
const fromEnv = process.env.NAVSPHERE_WEBPACK_PARALLELISM;
const n = fromEnv ? parseInt(fromEnv, 10) : NaN;
config.parallelism =
Number.isFinite(n) && n > 0
? n
: getBuildProfile().parallelism;
}
return config;
},
images: {
domains: [
"dash.cloudflare.com",
"www.google.com",
"ph-static.imgix.net",
"app.leonardo.ai",
],
remotePatterns: [
{
protocol: "https",
hostname: "**",
},
],
},
async rewrites() {
return [
{
source: "/api/auth/:path*",
destination: "/api/auth/:path*",
},
{
source: "/auth/:path*",
destination: "/auth/:path*",
},
];
},
// Cloudflare Pages configuration
experimental: {
serverActions: {
allowedOrigins: ["localhost", "navsphere.com", "*.hackrobot.cn"],
},
// 按需解析 barrel 导出,减轻构建时 AST/模块图压力
optimizePackageImports: [
"lucide-react",
"date-fns",
"recharts",
"@tanstack/react-table",
"@tanstack/react-query",
"@hello-pangea/dnd",
"@radix-ui/react-accordion",
"@radix-ui/react-alert-dialog",
"@radix-ui/react-aspect-ratio",
"@radix-ui/react-avatar",
"@radix-ui/react-checkbox",
"@radix-ui/react-collapsible",
"@radix-ui/react-context-menu",
"@radix-ui/react-dialog",
"@radix-ui/react-dropdown-menu",
"@radix-ui/react-hover-card",
"@radix-ui/react-label",
"@radix-ui/react-menubar",
"@radix-ui/react-navigation-menu",
"@radix-ui/react-popover",
"@radix-ui/react-progress",
"@radix-ui/react-radio-group",
"@radix-ui/react-scroll-area",
"@radix-ui/react-select",
"@radix-ui/react-separator",
"@radix-ui/react-slider",
"@radix-ui/react-slot",
"@radix-ui/react-switch",
"@radix-ui/react-tabs",
"@radix-ui/react-toast",
"@radix-ui/react-toggle",
"@radix-ui/react-toggle-group",
"@radix-ui/react-toolbar",
"@radix-ui/react-tooltip",
],
},
// 加在这句话就够了
generateBuildId: async () => {
return "v" + new Date().getTime();
},
headers: async () => [
{
source: "/:path*",
headers: [
{ key: "Cache-Control", value: "no-cache, no-store, must-revalidate" },
],
},
],
};
module.exports = nextConfig;