openclaw/apps/web/next.config.ts
kumarabhirup dbddde9477
Web app: switch to Next.js standalone build for npm packaging
Ship a self-contained standalone server with the npm package so
`npm i -g ironclaw` can serve the web UI without runtime `npm install`
or `next build`. This eliminates the fragile first-boot build step
and cuts the cold-start time for the gateway web app.

Changes:

- next.config.ts: enable `output: "standalone"` and set
  `outputFileTracingRoot` to the monorepo root so pnpm workspace
  deps are traced correctly. Remove the now-unnecessary manual
  webpack externals for Node.js built-ins.

- package.json: update `files` to ship only the standalone build
  output, static assets, and public dir (instead of the entire
  `apps/web/` tree). Add `web:build` and `web:prepack` to the
  `prepack` script so the standalone server is built and its
  static/public assets are copied into place before publish. Bump
  version to 2026.2.10-1.5.

- server-web-app.ts: rewrite the web app lifecycle to prefer the
  pre-built standalone `server.js` in production. Add
  `resolveStandaloneServerJs`, `hasStandaloneBuild`,
  `hasLegacyNextBuild`, and `isInWorkspace` helpers. In dev
  workspaces, fall back to building on-the-fly or legacy
  `next start`. Export key functions for testability.

- server-web-app.test.ts: add comprehensive unit tests covering
  path resolution, standalone/legacy build detection,
  ensureWebAppBuilt scenarios (skip, disabled, dev, standalone,
  legacy, missing), startWebAppIfEnabled (skip, disabled, null
  config, missing dir, standalone start, missing build error,
  default port, graceful stop).

- workspace-sidebar.tsx: update sidebar branding to "Ironclaw".

Published as ironclaw@2026.2.10-1.5.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 19:03:01 -08:00

23 lines
817 B
TypeScript

import type { NextConfig } from "next";
import path from "node:path";
const nextConfig: NextConfig = {
// 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, "..", ".."),
// Allow long-running API routes for agent streaming
serverExternalPackages: [],
// Transpile ESM-only packages so webpack can bundle them
transpilePackages: ["react-markdown", "remark-gfm"],
};
export default nextConfig;