New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

license-banner-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

license-banner-webpack-plugin

append license banner to bundle file.

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-46.15%
Maintainers
1
Weekly downloads
 
Created
Source

license-banner-webpack-plugin

Insert the license text of the module used for each bundled file at the beginning of each.

Install

$ yarn add license-banner-webpack-plugin --dev
# or
$ npm install license-banner-webpack-plugin --save-dev

Usage

Import the plugin module into webpack configuration.

const LicenseBannerPlugin = require('license-banner-webpack-plugin');

Then use this plugin with some options.

new LicenseBannerPlugin({
  licenseTemplate: function(pkg) {
    return `${pkg.name}, ${pkg.version}, ${pkg.author}, ${pkg.license}, ${pkg.repository}`;
  },
  licenseDirectories: [
    path.join('/path/to/node_modules')
  ]
});

Then output file has license banner like this.

/*
webpack@2.2.1
  license: MIT
  author: Tobias Koppers @sokra
  repository: https://github.com/webpack/webpack.git:
(...and any other modules you use in your code)
*/
options
new LicenseBannerPlugin(options);
nametypedescription
licenseTemplate(pkg)Functionlicense template pattern. argument pkg is each packages information object. you can use pkg.name pkg.version pkg.author pkg.license pkg.repository.
licenseDirectoriesArraypackage modules directories. The default is node_modules directory.

Removing all other comments

If you want to remove all other comments, use uglifyjs-webpack-plugin instead of plugins in webpack.

$ npm install uglifyjs-webpack-plugin --save-dev
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

and also you must be set behind UglifyJSPlugin.

// ...
  plugins: [
    new UglifyJSPlugin(),
    new LicenseBannerPlugin()
  ]
// ...

production mode (at webpack v4)

mode option has added from webpack v4.

If you use production mode and also want to use license-banner-webpack-plugin, you must set optimization.minimize option to false.

// ...
  mode: 'production',
  optimization: {
    minimize: false
  }
// ...

License

MIT

Author

RyotaSugawara

Keywords

FAQs

Package last updated on 06 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc