> ## Documentation Index
> Fetch the complete documentation index at: https://docs.linktr.ee/llms.txt
> Use this file to discover all available pages before exploring further.

# linkapp build

> Create an optimized production build of your LinkApp

## Usage

```bash theme={"system"}
npx @linktr.ee/linkapp build [options]
```

Run from your LinkApp project root. The command produces a production-ready bundle in `dist/`.

## Options

| Flag          | Description                                          | Default |
| ------------- | ---------------------------------------------------- | ------- |
| `--sourcemap` | Emit source maps alongside the build for debugging   | `false` |
| `--profile`   | Print profiling hints (alias: `--analyze`)           | `false` |
| `--compress`  | Emit Brotli-compressed `.br` assets for CDN delivery | `false` |
| `-h, --help`  | Show usage information                               | -       |

`--analyze` is deprecated but works as an alias of `--profile`.

## What it does

1. Generates runtime assets in `.linkapp/` and builds with Rsbuild in production mode.
2. Copies `public/` into `dist/` and, if present, copies `app/icon.svg` to `dist/icon.svg`.
3. Writes content-hashed JS/CSS/assets plus `build-manifest.json` for asset mapping.
4. Prints a size summary (raw plus gzip/Brotli estimates for JS/CSS).
5. When profiling is requested, reminds you to inspect the bundle with your preferred tooling.

## Output

```
dist/
├── index.html
├── build-manifest.json
├── icon.svg            # only if app/icon.svg exists
├── assets/
│   ├── index-XXXXX.js
│   ├── index-XXXXX.css
│   └── vendor-XXXXX.js
└── ...other hashed assets
```

Filenames are content-hashed so you can cache safely. `.br` files appear alongside JS/CSS when you pass `--compress`.

## Working with source maps

Use `--sourcemap` when you need to debug production errors:

```bash theme={"system"}
npx @linktr.ee/linkapp build --sourcemap
```

Keep source maps private; they expose your original source.

## Profiling and analysis

```bash theme={"system"}
npx @linktr.ee/linkapp build --profile
```

The build completes normally and prints a reminder to analyze the output with your preferred bundle inspector. Combine with `--sourcemap` for more detail.

## When builds fail

* **Missing modules or typos:** fix the import path or install the dependency.
* **Static asset not found:** ensure files referenced from `public/` or `app/` exist.
* **Large bundles:** rebuild with `--sourcemap` and inspect the emitted asset sizes to spot oversized dependencies.
