close
  • English
  • Overview

    • Type:
    interface LibConfig extends EnvironmentConfig {
      autoExtension?: boolean;
      autoExternal?: AutoExternal;
      banner?: BannerAndFooter;
      bundle?: boolean;
      dts?: Dts;
      experiments?: { exe?: ExeOptions };
      externalHelpers?: boolean;
      footer?: BannerAndFooter;
      format?: Format;
      id?: string;
      outBase?: string;
      redirect?: Redirect;
      shims?: Shims;
      syntax?: Syntax;
      umdName?: Rspack.LibraryName;
    }
    
    type SharedLibConfig = Pick<
      LibConfig,
      | 'bundle'
      | 'autoExtension'
      | 'autoExternal'
      | 'redirect'
      | 'syntax'
      | 'externalHelpers'
      | 'banner'
      | 'footer'
      | 'shims'
      | 'outBase'
    >;
    
    interface RslibConfig extends RsbuildConfig, SharedLibConfig {
      lib: LibConfig[];
    }
    • Default: undefined

    • Required: true

    The lib configuration is an array of objects, each representing a distinct set of configurations. These include all Rsbuild configurations as well as Rslib-specific configurations, designed to generate different outputs.

    Shared lib configuration

    Some lib options can also be configured at the top level of RslibConfig as defaults for all lib items. The same option configured inside a lib item overrides the top-level value.

    The following options support top-level configuration:

    OptionDescription
    bundleWhether to bundle the library.
    autoExtensionWhether to automatically set JavaScript output file extensions.
    autoExternalWhether to automatically externalize dependencies.
    redirectConfigure import path redirects in output files.
    syntaxConfigure the JavaScript and CSS syntax target.
    externalHelpersWhether to import SWC helpers from @swc/helpers.
    bannerInject content into the top of output files.
    footerInject content into the bottom of output files.
    shimsConfigure shims for CommonJS and ESM output.
    outBaseConfigure the base directory of bundleless output files.