Giter Club home page Giter Club logo

license-banner-webpack-plugin's Introduction

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.

/*
[email protected]
  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);
name type description
licenseTemplate(pkg) Function license template pattern. argument pkg is each packages information object. you can use pkg.name pkg.version pkg.author pkg.license pkg.repository.
licenseDirectories Array package 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

license-banner-webpack-plugin's People

Contributors

nulltask avatar ryotasugawara avatar yuheiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

nulltask mkwtys

license-banner-webpack-plugin's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.