For AI agents: the complete documentation index is available at https://rsbuild.rs/llms.txt, the full documentation bundle is available at https://rsbuild.rs/llms-full.txt, and this page is available as Markdown at https://rsbuild.rs/config/output/legal-comments.md.
close

output.legalComments

  • Type: 'linked' | 'inline' | 'none'
  • Default: 'linked'

Controls how legal comments are handled by the built-in JavaScript minifier. This option takes effect when JavaScript minification is enabled and does not control CSS comments.

Legal comments are JavaScript comments that contain @license or @preserve, or start with //! or /*!. By default, Rsbuild extracts them into separate license files.

For example, the LICENSE comment in React:

/**
 * @license React
 * react.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

Optional values

You can control how legal comments are handled using these options:

linked

Extracts all legal comments to *.LICENSE.txt files and links to them with a comment.

rsbuild.config.js
export default {
  output: {
    legalComments: 'linked',
  },
};

.LICENSE.txt files are not loaded by the page, so they will not affect the page's performance.

inline

Preserves legal comments in the minified JavaScript. This may increase the size of the output bundles.

rsbuild.config.js
export default {
  output: {
    legalComments: 'inline',
  },
};

none

Removes all legal comments.

rsbuild.config.js
export default {
  output: {
    legalComments: 'none',
  },
};
Tip

Removing license comments may violate the terms of some software licenses. Please ensure you have the right to remove these comments before using this option.