npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

templated-license-webpack-plugin

v0.3.2

Published

Outputs licenses from 3rd party libraries to a file

Downloads

5

Readme

Templated License Webpack Plugin

Build Status

This webpack plugin finds all 3rd party libraries used in a webpack build whose licenses match a given regex, and outputs the licenses for each package in your webpack build directory.

Installation

npm install templated-license-webpack-plugin --save-dev

Usage

First, import the plugin into your webpack configuration:

var TemplatedLicenseWebpackPlugin = require('templated-license-webpack-plugin');

The plugin requires you to specify a regular expression for licenses to match under the pattern property.

To use the plugin, simply add it to your webpack config's plugin list.

The below example matches MIT, ISC, and any license starting with BSD. This example will also throw an error and terminate your build if it finds a license containing GPL in it.

new TemplatedLicenseWebpackPlugin({
  pattern: /^(MIT|ISC|BSD.*)$/,
  unacceptablePattern: /GPL/,
  abortOnUnacceptableLicense: true,
  licenseTemplate: (mod) => `${mod.name} v${mod.version} (${mod.url})\n\n${mod.licenseText}`
});

Below are all options that can be passed to the plugin:

  • licenseTemplate A function that takes in module information and returns the license string to be inserted into the file
  • pattern A regular expression of license names to match. The license is read from the license property in package.json for each module used in your webpack output.
  • unacceptablePattern A regular expression of license names that are unacceptable for the build.
  • abortOnUnacceptableLicense Used only in conjunction with the unacceptablePattern option, setting this to true will cause the plugin to throw an error and abort the build if an unacceptable license is found.
  • filename This is the output filename which gets written your webpack build directory. The default is 3rdpartylicenses.txt.
  • includeUndefined whether include packages without license or not. The default is false
  • addLicenseText whether include license text to output file or not. The default is true
  • addUrl whether include url to repository to output file or not. The default is false
  • licenseFilenames A list of license filenames to match, in order of priority. The default is ['LICENSE', 'LICENSE.md', 'LICENSE.txt', 'license', 'license.md', 'license.txt']
  • licenseTemplateDir Directory containing .txt files corresponding to SPDX license identifiers. This directory is referred to when the plugin cannot find a license file per the licenseFilenames property. Typically you would clone the SPDX master files repository and use the resulting directory containing all the various license .txt as the licenseTemplateDir for the plugin.
  • licenseOverrides An object whose keys are module names and values are filenames to use for the license file. Used when you want to override a license file for a particular module.
  • licenseTypeOverrides An object whose keys are module names and values are SPDX license identifier strings (e.g. 'MIT'). Allows you to override the license type for any module.
  • suppressErrors (default: false) Set to true to avoid having the plugin write error messages to the console

If a license file cannot be found and includeUndefined property is set to false, the plugin will write whatever the license property contains in the module's package.json and print an error.

License

ISC