lib.outBase

  • Type: string
  • Default Value: undefined
INFO

outBase is a specific configuration for bundleless mode. This configuration does not take effect in bundle mode because all output files are bundled into a single file, so there's no need to determine the base output directory.

When building a project where source files exist across multiple directories with bundleless mode, the output directory structure will be replicated relative to the outBase directory in the output directory. If no base output directory is specified, the lowest common ancestor of all input entry points is used by default.

Configuring outBase will change the path of the base output directory. outBase can be either a relative path from the current process directory or an absolute path.

For example, we have the following directory structure:

.
├── package.json
├── rslib.config.ts
└── src
    └── utils
        ├── bar
        │   └── index.ts
        ├── foo
        │   └── index.ts
        └── index.ts

If the output base directory is not specified, the lowest common ancestor of all input entry point paths, i.e. ./src/utils, is used by default, and the final file output structure is:

dist
├── bar
│   └── index.js
├── foo
│   └── index.js
└── index.js

When outBase is configured as ./src, the output directory structure is:

dist
└── utils
    ├── bar
    │   └── index.js
    ├── foo
    │   └── index.js
    └── index.js
TIP

When the project needs to generate declaration files, to ensure that the generated declaration files and JS files maintain a consistent output directory structure, if you modify the outBase configuration, you need to make sure that the rootDir in tsconfig.json to the same path.