Skip to content

Config File

Centralize your build settings with a configuration file when CLI options aren't enough.

Getting Started

Create a bunup.config.ts file in your project root:

bunup.config.ts
ts
import { defineConfig } from 'bunup';

export default defineConfig({
  // ...your configuration options go here
});

This is the simplest way to centralize and reuse your build configuration. See Options for all the available options.

Multiple Configurations

Bunup supports exporting an array of configurations, useful when you want to build for multiple environments or formats in a single run:

bunup.config.ts
ts
export default defineConfig([
  {
    entry: "src/index.ts",
    name: 'node',
    format: 'esm',
    target: 'node',
  },
  {
    entry: "src/browser.ts",
    name: 'browser',
    format: ['esm', 'iife'],
    target: 'browser',
    outDir: 'dist/browser',
  },
]);

With this setup, Bunup will build both Node.js and browser bundles.

Another example: if you have different entry points that need different build configurations, you can specify them separately. For instance, your main module might need both ESM and CJS formats, while a CLI entry point might only need ESM:

bunup.config.ts
ts
export default defineConfig([
  {
    entry: "src/index.ts",
    format: ['esm', 'cjs'],
  },
  {
    entry: "src/cli.ts",
    format: ['esm'],
  },
]);

Named Configurations

Each build configuration can have a name. This improves log readability, especially when running multiple builds.

sh
bunup --name my-library
ts
export default defineConfig({
  name: 'my-library',
});

When working with multiple configurations, naming helps identify each build clearly:

bunup.config.ts
ts
export default defineConfig([
  {
    name: 'node-build',
    entry: "src/index.ts",
    format: 'esm',
    target: 'node',
    // ...other options
  },
  {
    name: 'browser-build',
    entry: "src/browser.ts",
    format: ['esm', 'iife'],
    target: 'browser',
    // ...other options
  },
]);

Custom Configuration Path

If you need to use a configuration file with a non-standard name or location, you can specify its path using the --config CLI option:

sh
bunup --config ./configs/custom.bunup.config.ts
# or using alias
bunup -c ./configs/custom.bunup.config.ts

This allows you to keep your configuration files organized in custom locations or use different configuration files for different environments.

Disabling Configuration Files

To explicitly disable config file usage and rely only on CLI options:

CLI
sh
bunup --no-config

Released under the MIT License.