@cyclonedx/webpack-plugin

中文文档
5.3.3发布于 2026/08/11Apache-2.0TypeScriptCommonJS构建来源已验证近 30 天下载 12.8万

Creates CycloneDX Software Bill of Materials (SBoM) from webpack projects

原始使用文档
文档目录12 节
  1. Requirements
  2. Installing
  3. Usage
  4. Options & Configuration
  5. Example
  6. Support for IETF /.well-known/sbom
  7. Use with Angular
  8. Use with React
  9. Use with Vue
  10. Internals
  11. Development & Contributing
  12. License

CycloneDX webpack plugin

shield_npm-version shield_gh-workflow-test shield_coverage shield_ossf-best-practices shield_license
shield_website shield_slack shield_groups shield_twitter-follow


This plugin for webpack creates a CycloneDX Software Bill of Materials (SBoM) containing an aggregate of all bundled dependencies.
This is probably the most accurate, complete SBOM generator for webpack-based builds.

This plugin uses the linkages generated by webpack to create a dependency graph which only contain the dependencies that are actually used (after tree-shaking).

The resulting SBOM documents follow official specifications and standards.

Requirements

  • Node.js >= 20.18
  • webpack ^5

However, there are older versions of this plugin, that support

  • Node.js v8.0.0 or higher
  • webpack v4.0.0 or higher

Installing

npm i -D @cyclonedx/webpack-plugin
yarn add -D @cyclonedx/webpack-plugin

Usage

new CycloneDxWebpackPlugin(options?: object)

Options & Configuration

NameTypeDefaultDescription
specVersion{string}
one of: "1.2", "1.3", "1.4", "1.5", "1.6", "1.7"
"1.6"Which version of CycloneDX-spec to use.
Supported values depend on the installed dependency CycloneDX-javascript-library.
reproducibleResults{boolean}falseWhether to go the extra mile and make the output reproducible.
Reproducibility might result in loss of time- and random-based-values.
validateResults{boolean}trueWhether to validate the BOM result.
Validation is skipped, if requirements not met. Requires transitive optional dependencies.
outputLocation{string}"./cyclonedx"Path to write the output to. The path is relative to webpack's overall output path.
includeWellknown{boolean}trueWhether to write the Wellknowns.
wellknownLocation{string}"./.well-known"Path to write the Wellknowns to. The path is relative to webpack's overall output path.
rootComponentAutodetect{boolean}trueWhether to try auto-detection of the RootComponent.
Tries to find the nearest package.json and build a CycloneDX component from it, so it can be assigned to bom.metadata.component.
rootComponentType{string}"application"Set the RootComponent's type.
See the list of valid values. Supported values depend on CycloneDX-javascript-library's enum ComponentType.
rootComponentNameoptional {string}undefinedIf rootComponentAutodetect is disabled, then this value is assumed as the "name" of the package.json.
rootComponentVersionoptional {string}undefinedIf rootComponentAutodetect is disabled, then this value is assumed as the "version" of the package.json.
rootComponentVCSoptional {string}undefinedIf rootComponentAutodetect is disabled or the Version Control System is not declared in the package.json, then this value is used as the URL for RootComponent's External References' of type "vcs".
rootComponentBuildSystemoptional {string}undefinedSet the URL for RootComponent's External References' of type "build-system".
This behavior is regardless of rootComponentAutodetect's status.
collectEvidence{boolean}falseWhether to collect (license) evidence and attach them to the resulting SBOM.

Example

In your webpack config add the CycloneDX plugin:

const { CycloneDxWebpackPlugin } = require('@cyclonedx/webpack-plugin');

/** @type {import('@cyclonedx/webpack-plugin').CycloneDxWebpackPluginOptions} */
const cycloneDxWebpackPluginOptions = {
  specVersion: '1.7',
  outputLocation: './bom'
}

module.exports = {
  // ...
  plugins: [
    new CycloneDxWebpackPlugin(cycloneDxWebpackPluginOptions)
  ]
}

See extended examples.

Support for IETF /.well-known/sbom

The CycloneDX webpack plugin supports placing the CycloneDX SBOM in a pre-defined location, specifically in /.well-known/sbom. This option is enabled by default. The behavior can be changed by overriding the values of includeWellknown and wellknownLocation.
See draft-ietf-opsawg-sbom-access for more information on the specification, currently an IETF draft.

In your webpack config add the CycloneDX plugin:

const { CycloneDxWebpackPlugin } = require('@cyclonedx/webpack-plugin');

/** @type {import('@cyclonedx/webpack-plugin').CycloneDxWebpackPluginOptions} */
const cycloneDxWebpackPluginOptions = {
  includeWellknown: true,
  wellknownLocation: './.well-known'
}

module.exports = {
  // ...
  plugins: [
    new CycloneDxWebpackPlugin(cycloneDxWebpackPluginOptions)
  ]
}

Use with Angular

Angular uses webpack under the hood. Therefore, it is possible to integrate this plugin by utilizing @angular-builders/custom-webpack.
See an example here: integration with Angular17/webpack5.

Use with React

React uses webpack under the hood. Therefore, it is possible to integrate this plugin.
See an example here: integration with React18/webpack5.

Use with Vue

Vue uses webpack under the hood. Therefore, it is possible to integrate this plugin.
See an example here: integration with Vue2/webpack5.

Internals

This webpack plugin utilizes the CycloneDX library to generate the actual data structures.

Besides the class CycloneDxWebpackPlugin and the interface CycloneDxWebpackPluginOptions,
this webpack plugin does not expose any additional public API or classes - all code is intended to be internal and might change without any notice during version upgrades.

Development & Contributing

Feel free to open issues, bugreports or pull requests.
See the CONTRIBUTING file for details.

License

Permission to modify and redistribute is granted under the terms of the Apache 2.0 license.
See the LICENSE file for the full license.

版本与发布记录

@cyclonedx/webpack-plugin 共发布 62 个版本,首次发布于 2021/09/12;过去 12 个月发布了 13 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.3.3latest2026/08/112 个月前
5.3.3-rc.7unstable-prerelease2026/08/112 个月前
5.3.3-rc.42026/07/283 个月前
5.3.3-rc.32026/07/283 个月前
5.3.3-rc.22026/07/283 个月前
5.3.3-rc.12026/07/283 个月前

关于 @cyclonedx/webpack-plugin 的常见问题

@cyclonedx/webpack-plugin 是什么?

Creates CycloneDX Software Bill of Materials (SBoM) from webpack projects

如何安装 @cyclonedx/webpack-plugin?

在项目目录运行 npm install @cyclonedx/webpack-plugin,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:webpack(^5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cyclonedx/webpack-plugin 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cyclonedx/webpack-plugin 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cyclonedx/webpack-plugin 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.18.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cyclonedx/webpack-plugin 可以商用吗?

@cyclonedx/webpack-plugin 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cyclonedx/webpack-plugin 的下载量有多少?

根据 npm 官方下载统计,@cyclonedx/webpack-plugin 在 2026/10/11 – 2026/11/09 这 30 天内被下载 128,228 次,日均约 4,274 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cyclonedx/webpack-plugin 还在维护吗?

最新版本 5.3.3 发布于 2026/08/11(2 个月前);至今共发布 62 个版本,其中过去 12 个月发布了 13 个;首次发布于 2021/09/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。