openclaw/apps/web/next.config.ts
kumarabhirup aa97489785
👌 IMPROVE: feat(telemetry): add DenchClaw and OpenClaw version tracking
Integrate version tracking for DenchClaw and OpenClaw into the telemetry system. The versions are now read from the package.json and environment variables, and are included in the PostHog client initialization and telemetry events. This enhancement allows for better monitoring and analytics of the versions in use.
2026-03-15 04:33:44 -07:00

68 lines
2.1 KiB
TypeScript

import type { NextConfig } from "next";
import { readFileSync } from "node:fs";
import path from "node:path";
import { homedir } from "node:os";
import { createRequire } from "node:module";
const rootPkg = JSON.parse(
readFileSync(path.join(import.meta.dirname, "..", "..", "package.json"), "utf-8"),
) as { version?: string };
let openclawVersion = "";
try {
const req = createRequire(import.meta.url);
const oclPkg = req("openclaw/package.json") as { version?: string };
openclawVersion = oclPkg.version ?? "";
} catch { /* openclaw not resolvable at build time */ }
const nextConfig: NextConfig = {
env: {
NEXT_PUBLIC_DENCHCLAW_VERSION: rootPkg.version ?? "",
NEXT_PUBLIC_OPENCLAW_VERSION: openclawVersion,
},
// Produce a self-contained standalone build so npm global installs
// can run the web app with `node server.js` — no npm install or
// next build required at runtime.
output: "standalone",
// Required for pnpm monorepos: trace dependencies from the workspace
// root so the standalone build bundles its own node_modules correctly
// instead of resolving through pnpm's virtual store symlinks.
outputFileTracingRoot: path.join(import.meta.dirname, "..", ".."),
// Externalize packages with native addons so webpack doesn't break them
serverExternalPackages: ["ws", "bufferutil", "utf-8-validate", "node-pty"],
// Transpile ESM-only packages so webpack can bundle them
transpilePackages: ["react-markdown", "remark-gfm"],
webpack: (config, { dev, isServer }) => {
if (!isServer) {
// html-to-docx references Node-only modules that should not be resolved in browser bundles.
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
encoding: false,
};
}
if (dev) {
config.watchOptions = {
...config.watchOptions,
ignored: [
"**/node_modules/**",
"**/.git/**",
"**/dist/**",
"**/.next/**",
path.join(homedir(), ".openclaw", "**"),
path.join(homedir(), ".openclaw-*", "**"),
],
poll: 1500,
};
}
return config;
},
};
export default nextConfig;