Pcompile
Bun

property

BuildConfig.compile

compile?: boolean | CompileTarget | CompileBuildOptions

Create a standalone executable or self-contained HTML.

When true, creates an executable for the current platform. When a target string, creates an executable for that platform.

When used with target: "browser", produces self-contained HTML files with all scripts, styles, and assets inlined. All <script> tags become inline <script> with bundled code, all <link rel="stylesheet"> tags become inline <style> tags, and all asset references become data: URIs. All entrypoints must be HTML files. Cannot be used with splitting.

// Create executable for current platform
await Bun.build({
  entrypoints: ['./app.js'],
  compile: {
    target: 'linux-x64',
  },
  outfile: './my-app'
});

// Cross-compile for Linux x64
await Bun.build({
  entrypoints: ['./app.js'],
  compile: 'linux-x64',
  outfile: './my-app'
});

// Produce self-contained HTML
await Bun.build({
  entrypoints: ['./index.html'],
  target: 'browser',
  compile: true,
});