Files
mnote/wolai-frontend/next.config.ts
T

40 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-11-23 10:55:04 +08:00
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
2026-01-15 20:54:21 +08:00
// 供桌面端打包使用(Electron 内置 Next server.js + 最小依赖)。
// 说明:`pnpm run build:desktop:next` 会依赖该产物。
output: "standalone",
2026-01-10 10:35:21 +08:00
turbopack: {
// 避免 monorepo/多 lockfile 场景下 root 误判,减少构建与热更新的不确定性
root: __dirname,
},
2026-01-11 12:35:53 +08:00
async headers() {
// 说明:ONLYOFFICE 文档服务器会在其 iframe 内跨域拉取插件 manifest/js/html。
// 这里对插件资源放开 CORS,避免 pluginsData 加载失败。
return [
2026-01-15 20:54:21 +08:00
// 说明:远程通过 Cloudflare Tunnel 访问时,Next.jsTurbopack dev)默认对
// `/_next/static/chunks/*` 返回 `no-store`,导致 Cloudflare 无法缓存大体积
// bundle,网络稍慢时会出现页面长期停留在“正在载入编辑器...”的现象。
// 这些资源带 hash 文件名,设置 immutable 不会导致更新不一致。
{
source: "/_next/static/chunks/:path*",
headers: [{ key: "Cache-Control", value: "public, max-age=31536000, immutable" }],
},
{
source: "/_next/static/media/:path*",
headers: [{ key: "Cache-Control", value: "public, max-age=31536000, immutable" }],
},
2026-01-11 12:35:53 +08:00
{
source: "/onlyoffice/plugins/:path*",
headers: [
{ key: "Access-Control-Allow-Origin", value: "*" },
{ key: "Access-Control-Allow-Methods", value: "GET,OPTIONS" },
{ key: "Access-Control-Allow-Headers", value: "*" },
],
},
];
},
2025-11-23 10:55:04 +08:00
};
export default nextConfig;