Configuration: Overview

Configuration is set by JSON. Config files can be written in TypeScript, JavaScript, JSON, or JSONC.

See Root Configuration and Workspace Configuration for more information on the purpose of each field.

Quick Examples

Project Root Configuration

The root configuration is for project-wide settings.

// path/to/your/project/bw.root.ts

import { defineRootConfig } from "bun-workspaces/config";

export default defineRootConfig({
  defaults: {
    parallelMax: 4,
    shell: "system",
    includeRootWorkspace: false,
    affectedBaseRef: "my-branch"
  },
  workspacePatternConfigs: [
    {
      patterns: [
        "path:libraries/frontend/**/*"
      ],
      config: {
        tags: [
          "frontend",
          "library"
        ]
      }
    }
  ]
});

Workspace Configuration

Workspace configurations are defined in the directory of a workspace.

// path/to/your/project/workspace/bw.workspace.ts

import { defineWorkspaceConfig } from "bun-workspaces/config";

export default defineWorkspaceConfig({
  alias: "myApp",
  tags: [
    "my-tag"
  ],
  scripts: {
    start: {
      order: 10
    },
    test: {
      order: 20
    }
  },
  rules: {
    workspaceDependencies: {
      allowPatterns: [
        "my-workspace-a",
        "tag:my-tag",
        "path:my-path/**/*",
        "not:tag:my-excluded-tag"
      ]
    }
  }
});

Config Locations / File Types

Configuration locations

Configuration files can be read from the following location. The first to be resolved in this order will be used:

  1. TypeScript file: bw.<name>.ts
  2. JavaScript file: bw.<name>.js
  3. JSONC file: bw.<name>.jsonc
  4. JSON file: bw.<name>.json
  5. package.json key: package.json["<key>"]

Value Resolution

Values related to configuration are resolved in the following order of precedence:

  1. An explicit CLI or API argument/option passed to a method/function/command
  2. A value provided in a configuration file
  3. A value provided via an environment variable, if applicable
  4. The generic default value, if applicable