👌 IMPROVE: caching
This commit is contained in:
parent
f29bd0c5c1
commit
7fe870fec0
@ -15,12 +15,29 @@ try {
|
|||||||
openclawVersion = oclPkg.version ?? "";
|
openclawVersion = oclPkg.version ?? "";
|
||||||
} catch { /* openclaw not resolvable at build time */ }
|
} catch { /* openclaw not resolvable at build time */ }
|
||||||
|
|
||||||
|
const denchVersion = rootPkg.version ?? "";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
env: {
|
env: {
|
||||||
NEXT_PUBLIC_DENCHCLAW_VERSION: rootPkg.version ?? "",
|
NEXT_PUBLIC_DENCHCLAW_VERSION: denchVersion,
|
||||||
NEXT_PUBLIC_OPENCLAW_VERSION: openclawVersion,
|
NEXT_PUBLIC_OPENCLAW_VERSION: openclawVersion,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async headers() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: "/((?!_next/static|_next/image|favicon\\.ico).*)",
|
||||||
|
headers: [
|
||||||
|
{
|
||||||
|
key: "Cache-Control",
|
||||||
|
value: "private, no-cache, no-store, max-age=0, must-revalidate",
|
||||||
|
},
|
||||||
|
{ key: "X-Denchclaw-Version", value: denchVersion },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
|
||||||
// Produce a self-contained standalone build so npm global installs
|
// Produce a self-contained standalone build so npm global installs
|
||||||
// can run the web app with `node server.js` — no npm install or
|
// can run the web app with `node server.js` — no npm install or
|
||||||
// next build required at runtime.
|
// next build required at runtime.
|
||||||
|
|||||||
@ -694,10 +694,13 @@ function ensureSeedAssets(runtimeAppDir: string, packageRoot: string): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy .next/static/ and public/ into the runtime app dir if they aren't
|
* Copy .next/static/ and public/ into the runtime app dir. Always
|
||||||
* already present. In production the prepack script copies these into the
|
* force-overwrites so stale assets left by a partial prior install or an
|
||||||
* standalone app dir before publish, so cpSync already picks them up.
|
* npx cache hit are replaced with the current build.
|
||||||
* In dev the prepack hasn't run, so we pull them from the source tree.
|
*
|
||||||
|
* In production the prepack script already embeds these in the standalone
|
||||||
|
* app dir, so cpSync picks them up first; this pass guarantees they match
|
||||||
|
* the source tree even when the standalone copy is incomplete.
|
||||||
*/
|
*/
|
||||||
function ensureStaticAssets(runtimeAppDir: string, packageRoot: string): void {
|
function ensureStaticAssets(runtimeAppDir: string, packageRoot: string): void {
|
||||||
const pairs: Array<[src: string, dst: string]> = [
|
const pairs: Array<[src: string, dst: string]> = [
|
||||||
@ -711,7 +714,7 @@ function ensureStaticAssets(runtimeAppDir: string, packageRoot: string): void {
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
for (const [src, dst] of pairs) {
|
for (const [src, dst] of pairs) {
|
||||||
if (existsSync(dst) || !existsSync(src)) continue;
|
if (!existsSync(src)) continue;
|
||||||
try {
|
try {
|
||||||
mkdirSync(path.dirname(dst), { recursive: true });
|
mkdirSync(path.dirname(dst), { recursive: true });
|
||||||
cpSync(src, dst, { recursive: true, dereference: true, force: true });
|
cpSync(src, dst, { recursive: true, dereference: true, force: true });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user