web-infra-dev / rslib

Create JavaScript libraries in a simple and intuitive way.
https://lib.rsbuild.dev/
MIT License
392 stars 20 forks source link

feat: support `banner` and `footer` #175

Closed Timeless0911 closed 2 months ago

Timeless0911 commented 2 months ago

Summary

This PR implements the banner and footer feature.

We use bannerPlugin of Rspack to add banner and footer in js/css build.

Notice:

  1. only string type is supported and will not be wrapped in a comment.
  2. The default stage is PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1 to prevent avoid influence of minimizers
  3. If you have further demand on banner and footer, you can directly use bannerPlugin.
type BannerAndFooter = {
  js?: string;
  css?: string;
  dts?: string;
};

interface LibConfig extends RsbuildConfig {
  banner?: BannerAndFooter;
  footer?: BannerAndFooter;
}

Since support of css of bundleless mode is not ready, we ignore css banner and footer tests in bundleless mode.

Related Links

Checklist