Giter VIP home page Giter VIP logo

license-info-webpack-plugin's Introduction

license-info-webpack-plugin

npm version

license-info-webpack-plugin is a webpack plugin for making a list of package's LICENSE information, inspired by licensify.

$ npm install --save-dev license-info-webpack-plugin
$ yarn add --dev license-info-webpack-plugin

Usage

webpack v4

If you use webpack < 4.2 that has dependency on uglifyjs-webpack-plugin < 1.2.4, you need to set optimization to set uglifyOptions.

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

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

webpack v3

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

module.exports = {
  entry: './src/js/index.js',
  output: {
    path: path.join(__dirname, 'dist/js'),
    filename: '[name].js'
  },
  plugins: [
    new LicenseInfoWebpackPlugin({
      glob: '{LICENSE,license,License}*'
    }),
    new UglifyJsPlugin({
      uglifyOptions: {
        output: {
          comments: /^\**!|@preserve|@license|@cc_on/
        }
      }
    })
  ]
};

Note

If you use uglifyjs-webpack-plugin@^1.2.4 or webpack has dependency on uglifyjs-webpack-plugin@^1.2.4, you don't need to set uglifyOptions for preserve license comments.
Related: webpack-contrib/uglifyjs-webpack-plugin#250

If you use uglifyjs-webpack-plugin@~1.1, you need to set uglifyOptions for preserve license comments.
Related: webpack-contrib/uglifyjs-webpack-plugin#174

license-info-webpack-plugin needs webpack v3.0 or above

Options

  • glob
    • Glob pattern for LICENSE file
    • Default: '{LICENSE,license,License}*'
  • outputType
    • Output type: 'banner' or 'html'
      • 'banner': Append comment to top of bundled code
      • 'html': Generate html (e.g. license.[name].html)
    • Default: 'banner'
  • includeLicenseFile
    • Include and put LICENSE file
    • Default: true

LICENSE

MIT

license-info-webpack-plugin's People

Contributors

a-haba avatar dependabot[bot] avatar renovate-bot avatar yami-beta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

a-haba

license-info-webpack-plugin's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository.

  • WARN: Partial matches for matchPaths are deprecated. Please use a minimatch glob pattern or switch to matchFiles if you need exact matching.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency babel-loader to ^8.3.0
  • Update actions/checkout action to v3
  • Update actions/setup-node action to v3
  • Update dependency @types/node to v18
  • Update dependency babel-loader to v9
  • Update dependency glob to v10
  • Update dependency typescript to v5
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v1
  • actions/setup-node v1
npm
package.json
  • glob ^7.1.7
  • webpack-sources ^1.4.3
  • @types/jest ^26.0.24
  • @types/node ^10.17.60
  • @typescript-eslint/eslint-plugin ^3.8.0
  • @typescript-eslint/parser ^3.8.0
  • eslint ^7.6.0
  • eslint-config-prettier ^6.11.0
  • eslint-plugin-prettier ^3.1.4
  • jest ^26.2.2
  • npm-run-all ^4.1.5
  • prettier ^2.0.5
  • ts-jest ^26.1.4
  • typescript ^3.9.10
test-v3/package.json
  • @babel/core ^7.11.6
  • @babel/preset-env ^7.11.5
  • babel-loader ^8.1.0
  • memfs ^3.2.4
  • uglifyjs-webpack-plugin ^1.3.0
  • webpack ^3.12
  • @types/jest ^26.0.24
  • jest ^26.2.2
  • ts-jest ^26.1.4
  • typescript ^3.9.10
test-v4/package.json
  • @babel/core ^7.11.6
  • @babel/preset-env ^7.11.5
  • babel-loader ^8.1.0
  • memfs ^3.2.4
  • webpack ^4.44.2
  • @types/jest ^26.0.24
  • jest ^26.2.2
  • ts-jest ^26.1.4
  • typescript ^3.9.10

  • Check this box to trigger a request for Renovate to run again on this repository

Broken when license file has multi-line comments

I use this plugin and one of my project's dependency module has a license file like this.

Licensing
---------

This software is covered under the following copyright:

/*
 * Copyright (c) 200x-201x  foo bar
 * All Rights Reserved.
 * Permission is hereby granted...
 * ...
 * All redistributions must retain an intact copy of this copyright notice
 * and disclaimer.
 */

Then, bundled file become like this.

/*
 * /*
 * * Copyright (c) 200x-201x  foo bar
 * * All Rights Reserved.
 * * Permission is hereby granted...
 * * ...
 * * All redistributions must retain an intact copy of this copyright notice
 * * and disclaimer.
 * */
 * 
 */

There is an error due to nested comments.

Could you please add an escape to the slash in the nested comments?

question of

Usage said "you need to set uglifyOptions for preserve license comments.",
but when below code, I can uglify with preserve license comments. Why?

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

module.exports = {

    entry: {
        'lc.test3': './js/src/main.js',
    },

    output: {
        path: path.join(__dirname, 'dist'),
        filename: '[name].js'
    },

    module: {
        rules: [
          {
            test: /\.js$/,
            exclude: /node_modules/,
            loader: "babel-loader",
            query:{
              presets: ['es2015']
            },
          },
          {
            test: /\.js$/,
            exclude: /node_modules/,
            options: {
              configFile: '.eslintrc',
            },
            loader: "eslint-loader",
          },
        ],
    },

//    optimization: {
//        minimizer: [
//            new UglifyJsPlugin({
//                uglifyOptions: {
//                    output: {
//                        comments: /^\**!|@preserve|@license|@cc_on/
//                    }
//                }
//            })
//        ]
//    },

    plugins: [
        new LicenseInfoWebpackPlugin({
            glob: '{LICENSE,license,License}*',
        }),
    ],

    resolve: {
        alias: {
            vue: 'vue/dist/vue.js'
        }
    },

};

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.