What is license-webpack-plugin?
The license-webpack-plugin is a plugin for Webpack that helps you to manage and automate the process of handling license information for the packages included in your bundle. It can generate a license file, include license texts in your bundle, and filter packages based on their licenses.
What are license-webpack-plugin's main functionalities?
Generate a license file
This feature allows you to generate a single file that contains all the license information for the packages included in your webpack bundle. The 'outputFilename' option specifies the name of the file to be created.
new LicenseWebpackPlugin({
outputFilename: 'licenses.txt'
})
Include license texts in the bundle
With this feature, you can include the license texts directly in your webpack bundle. Setting 'perChunkOutput' to false will include all licenses in the main bundle file instead of separate chunk files.
new LicenseWebpackPlugin({
perChunkOutput: false
})
Filter packages by license type
This feature allows you to filter which packages to include based on their license type. In this example, only packages with the 'MIT' license will be included.
new LicenseWebpackPlugin({
licenseInclusionTest: (licenseType) => licenseType === 'MIT'
})
Other packages similar to license-webpack-plugin
webpack-license-plugin
Similar to license-webpack-plugin, webpack-license-plugin also helps in managing licenses for third-party dependencies. It can generate a third-party notices file including all licenses. It differs in the way it handles the output and configuration options.
license-checker-webpack-plugin
This plugin is another alternative that scans your node_modules directory to check for licenses and outputs a summary of the license information. It is less focused on bundling the licenses with the webpack output and more on reporting and compliance.
License Webpack Plugin
Manage third-party license compliance in your webpack build.
Installation
npm install license-webpack-plugin --save-dev
Usage
To use the plugin, simply add it to the plugins section in the webpack config.
Example:
const LicenseWebpackPlugin = require('license-webpack-plugin').LicenseWebpackPlugin;
module.exports = {
plugins: [
new LicenseWebpackPlugin()
]
};
The default behavior will add a license notice file to each chunk of the webpack build. In addition, it will add a banner indicating the path to the license notice file in any Javascript assets. Third party libraries imported via external tools like SASS @import
may not appear in the output (since webpack does not process @import
). If this issue happens, please specify additional modules that the plugin should scan.
To configure the plugin, check the documentation.
Build Instructions
yarn
yarn build
Migration Guides
Migration guides for breaking changes are documented here.
Changelog
The changelog can be found here.
License
ISC