Skip to content

vercel target: let the build describe static assets, extra functions and routes #679

Closed

Description

@blove

Problem

b4 build with targets: ["vercel"] emits only the runtime function (.vercel/output/functions/index.func plus a catch-all config.json). A real app also ships static assets (a SPA) and its own HTTP endpoints beside /agui and /threads. Today that means post-processing the published tree with an external assembler (tools/vercel/assemble.mjs in hashbrown) that copies the function, adds a static dir with SPA fallback, bundles extra functions, and rewrites routes.

Proposal

Let the target describe the whole deployable tree so b4 build alone produces it:

config({
  build: {
    targets: ["vercel"],
    vercel: {
      static: { dir: "../dist/react", spaFallback: "index.html" },
      functions: { api: { entry: "src/api.ts", maxDuration: 30 } },
      routes: [{ src: "/api/(.*)", dest: "/api" }],
    },
  },
});

Related: #680 (output dir), #687 (function name).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions