## CLI Usage

```bash
bun build <entry points>
```

### General Configuration

<ParamField path="--production" type="boolean">
  Set <code>NODE_ENV=production</code> and enable minification
</ParamField>

<ParamField path="--bytecode" type="boolean">
  Use a bytecode cache when compiling
</ParamField>

<ParamField path="--bytecode-depth" type="number">
  How many levels of nested functions to compile to bytecode ahead of time (a non-negative integer). Defaults to all
</ParamField>

<ParamField path="--target" type="string" default="browser">
  Intended execution environment for the bundle. One of <code>browser</code>, <code>bun</code>, or <code>node</code>
</ParamField>

<ParamField path="--conditions" type="string">
  Pass custom resolution conditions
</ParamField>

<ParamField path="--env" type="string" default="disable">
  Inline environment variables into the bundle as <code>process.env.${name}</code>. To inline variables matching a
  prefix, use a glob like <code>FOO_PUBLIC_*</code>
</ParamField>

### Output & File Handling

<ParamField path="--outdir" type="string" default="dist">
  Output directory (used when building multiple entry points)
</ParamField>

<ParamField path="--outfile" type="string">
  Write output to a specific file
</ParamField>

<ParamField path="--metafile" type="string">
  Write a JSON file with metadata about the build
</ParamField>

<ParamField path="--metafile-md" type="string">
  Write a markdown file with a visualization of the module graph (LLM-friendly)
</ParamField>

<ParamField path="--sourcemap" type="string" default="none">
  Generate source maps. One of <code>linked</code>, <code>inline</code>, <code>external</code>, or <code>none</code>
</ParamField>

<ParamField path="--banner" type="string">
  Add a banner to the output (e.g. <code>"use client"</code> for React Server Components)
</ParamField>

<ParamField path="--footer" type="string">
  Add a footer to the output (e.g. <code>// built with bun!</code>)
</ParamField>

<ParamField path="--format" type="string" default="esm">
  Module format of the output bundle. One of <code>esm</code>, <code>cjs</code>, or <code>iife</code>. Defaults to{" "}
  <code>cjs</code> when <code>--bytecode</code> is used.
</ParamField>

### File Naming

<ParamField path="--entry-naming" type="string" default="[dir]/[name].[ext]">
  Customize entry point filenames
</ParamField>

<ParamField path="--chunk-naming" type="string" default="[name]-[hash].[ext]">
  Customize chunk filenames
</ParamField>

<ParamField path="--asset-naming" type="string" default="[name]-[hash].[ext]">
  Customize asset filenames
</ParamField>

### Bundling Options

<ParamField path="--root" type="string">
  Root directory used when bundling multiple entry points
</ParamField>

<ParamField path="--splitting" type="boolean">
  Enable code splitting for shared modules
</ParamField>

<ParamField path="--min-chunk-size" type="number">
  With `--splitting`, also fold side-effect-free chunks smaller than this many source bytes into a chunk loaded by a
  superset of their importers
</ParamField>

<ParamField path="--no-module-preload" type="boolean">
  With `--splitting` and `--target browser`, don't emit `<link rel="modulepreload">` for the chunks an entrypoint or
  `import()` depends on
</ParamField>

<ParamField path="--public-path" type="string">
  Prefix the bundler adds to import paths in bundled code
</ParamField>

<ParamField path="--external" type="string">
  Exclude modules from the bundle (supports wildcards). Alias: <code>-e</code>
</ParamField>

<ParamField path="--allow-unresolved" type="string" default="*">
  Allow unresolved dynamic import()/require() specifiers matching these glob patterns. Pass <code>''</code> to allow
  opaque specifiers
</ParamField>

<ParamField path="--reject-unresolved" type="boolean">
  Fail the build on any dynamic import()/require() specifier that cannot be resolved at build time
</ParamField>

<ParamField path="--packages" type="string" default="bundle">
  How to treat dependencies: <code>external</code> or <code>bundle</code>
</ParamField>

<ParamField path="--no-bundle" type="boolean">
  Transpile only — do not bundle
</ParamField>

<ParamField path="--css-chunking" type="boolean">
  Chunk CSS files together to reduce duplication (only when multiple entry points import CSS)
</ParamField>

### Minification & Optimization

<ParamField path="--emit-dce-annotations" type="boolean" default="true">
  Re-emit Dead Code Elimination annotations. Disabled when <code>--minify-whitespace</code> is used
</ParamField>

<ParamField path="--no-deprecated-namespace-object-setters" type="boolean">
  Emit getter-only module namespace objects (assigning to a property throws, like a real namespace). This becomes the
  default in a future release
</ParamField>

<ParamField path="--minify" type="boolean">
  Enable all minification options
</ParamField>

<ParamField path="--minify-syntax" type="boolean">
  Minify syntax and inline constants
</ParamField>

<ParamField path="--minify-whitespace" type="boolean">
  Minify whitespace
</ParamField>

<ParamField path="--minify-identifiers" type="boolean">
  Minify variable and function identifiers
</ParamField>

<ParamField path="--keep-names" type="boolean">
  Preserve original function and class names when minifying
</ParamField>

### Development Features

<ParamField path="--watch" type="boolean">
  Rebuild automatically when files change
</ParamField>

<ParamField path="--no-clear-screen" type="boolean">
  Don’t clear the terminal when rebuilding with <code>--watch</code>
</ParamField>

<ParamField path="--react-fast-refresh" type="boolean">
  Enable React Fast Refresh transform (for development testing)
</ParamField>

<ParamField path="--react-compiler" type="boolean">
  Run the React Compiler over `.jsx`/`.tsx` files, automatically memoizing components and hooks. The bundler derives the
  output mode from `--target` (`browser` → client, `bun`/`node` → ssr). Experimental.
</ParamField>

### Standalone Executables

<ParamField path="--compile" type="boolean">
  Generate a standalone Bun executable containing the bundle
</ParamField>

<ParamField path="--compile-exec-argv" type="string">
  Prepend arguments to the standalone executable’s <code>execArgv</code>
</ParamField>

<ParamField path="--compile-autoload-dotenv" type="boolean" default="true">
  Enable autoloading of <code>.env</code> files in the standalone executable
</ParamField>

<ParamField path="--no-compile-autoload-dotenv" type="boolean">
  Disable autoloading of <code>.env</code> files in the standalone executable
</ParamField>

<ParamField path="--compile-autoload-bunfig" type="boolean" default="true">
  Enable autoloading of <code>bunfig.toml</code> in the standalone executable
</ParamField>

<ParamField path="--no-compile-autoload-bunfig" type="boolean">
  Disable autoloading of <code>bunfig.toml</code> in the standalone executable
</ParamField>

<ParamField path="--compile-autoload-tsconfig" type="boolean" default="false">
  Enable autoloading of <code>tsconfig.json</code> at runtime in the standalone executable
</ParamField>

<ParamField path="--no-compile-autoload-tsconfig" type="boolean">
  Disable autoloading of <code>tsconfig.json</code> at runtime in the standalone executable
</ParamField>

<ParamField path="--compile-autoload-package-json" type="boolean" default="false">
  Enable autoloading of <code>package.json</code> at runtime in the standalone executable
</ParamField>

<ParamField path="--no-compile-autoload-package-json" type="boolean">
  Disable autoloading of <code>package.json</code> at runtime in the standalone executable
</ParamField>

<ParamField path="--compile-executable-path" type="string">
  Path to a Bun executable to use for cross-compilation instead of downloading
</ParamField>

<ParamField path="--asset" type="string">
  Embed a file or directory into the compiled executable under its basename; a directory keeps its internal tree, so{" "}
  <code>--asset ./static/public</code> embeds <code>public/...</code> (requires <code>--compile</code>)
</ParamField>

### Windows Executable Details

<ParamField path="--windows-hide-console" type="boolean">
  Prevent a console window from opening when running a compiled Windows executable
</ParamField>

<ParamField path="--windows-icon" type="string">
  Set an icon for the Windows executable
</ParamField>

<ParamField path="--windows-title" type="string">
  Set the Windows executable product name
</ParamField>

<ParamField path="--windows-publisher" type="string">
  Set the Windows executable company name
</ParamField>

<ParamField path="--windows-version" type="string">
  Set the Windows executable version (e.g. <code>1.2.3.4</code>)
</ParamField>

<ParamField path="--windows-description" type="string">
  Set the Windows executable description
</ParamField>

<ParamField path="--windows-copyright" type="string">
  Set the Windows executable copyright notice
</ParamField>

### Experimental & App Building

<ParamField path="--app" type="boolean">
  <b>(EXPERIMENTAL)</b> Build a web app for production using Bun Bake
</ParamField>

<ParamField path="--server-components" type="boolean">
  <b>(EXPERIMENTAL)</b> Enable React Server Components
</ParamField>

<ParamField path="--debug-dump-server-files" type="boolean">
  When <code>--app</code> is set, dump all server files to disk even for static builds
</ParamField>

<ParamField path="--debug-no-minify" type="boolean">
  When <code>--app</code> is set, disable all minification
</ParamField>
