License Info Webpack Plugin

raw JSON →
3.0.0 verified Sat Apr 25 auth: no javascript

A webpack plugin that collects LICENSE information from all dependencies and outputs it as a banner comment or separate HTML file. Current stable version is 3.0.0. It is inspired by licensify and supports webpack 3 and 4. Key differentiators include configurable glob patterns for license files, two output types (banner and HTML), and optional inclusion of the license file itself. The plugin handles preservation of license comments during minification when used with uglifyjs-webpack-plugin.

error TypeError: LicenseInfoWebpackPlugin is not a constructor
cause Using require without .default when the package uses ES module default export.
fix
const LicenseInfoWebpackPlugin = require('license-info-webpack-plugin').default;
error Error: Plugin could not be instantiated - options.glob is not a string
cause The glob option expects a string pattern; passing an array or other type.
fix
Set glob to a string like '{LICENSE,license,License}*'.
gotcha CommonJS require without .default returns an object, not the constructor.
fix Use require('license-info-webpack-plugin').default instead of require('license-info-webpack-plugin').
gotcha In webpack 4 with uglifyjs-webpack-plugin older than 1.2.4, license comments may be stripped without explicit uglifyOptions.
fix Set uglifyOptions in optimization to preserve comments with @license, @preserve, etc.
npm install license-info-webpack-plugin
yarn add license-info-webpack-plugin
pnpm add license-info-webpack-plugin

Demonstrates basic usage of the plugin in a webpack configuration, showing all available options.

const path = require('path');
const LicenseInfoWebpackPlugin = require('license-info-webpack-plugin').default;

module.exports = {
  mode: 'production',
  entry: './src/index.js',
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  plugins: [
    new LicenseInfoWebpackPlugin({
      glob: '{LICENSE,license,License}*',
      outputType: 'banner',
      includeLicenseFile: true
    })
  ]
};