4

I want to use NPM react-icons package that distributed under MIT license on my webpage. I'm using Webpack as my build/bundling tool and when it runs in the production mode its spits out minified js file that includes all libraries and my code in the same bundle. I want to include react-icons copyright and permissions notice before the actual react-icons code in the bundle.

How it could be achieved using Webpack?

2 Answers 2

4

It is possible that you don't have to include the license text and copyrights of dependencies directly into your output chunks. An alternative is generating a so called "bill of materials" file that contains a list of every package used, including version, license identifier and license text (which might include the copyright) for every package.

Check out webpack-license-plugin if this sounds like a good idea.

If you have any questions about the usage, feel free to open issues or ask here.

0

You can use the webpack banner plugin for this.

Example webpack.config.js:

const webpack = require('webpack');

module.exports = {

    /* ... other webpack config ... */

    plugins: [
        new webpack.BannerPlugin(
            'react-icons – copyright 2018 ' +
            'kamijin_fanta <[email protected]>')
    ]
};

This will make it so that each JavaScript bundle created by webpack starts with this comment:

/*! react-icons – copyright 2018 kamijin_fanta <[email protected]> */

Configuration options are explained in the plugin's documentation.

3
  • Thank you Patrick! Is it correct way to include license in the source code? I thought that you need to include license exactly before the code itself. I mean: if I have 5 libs bundled into one minified file, is it correct to pull 5 licenses altogether in the begging of the file? This concern is why i didn't used this plugin at the first place. Commented Oct 12, 2018 at 21:30
  • I‘m not an expert in licensing law, but afaik it’s not very common to include this info in js bundles at all. Most people just include it in the readmes of their source code repos on github, that’s what I also do for my own open source modules. But you may be right, the text of the mit license can be interpreted that way, that you have to include the copyright notes in your bundle. Surely interesting question, but not exactly what you asked originally Commented Oct 12, 2018 at 21:35
  • I think it depends on if you view the resulting "blob" an executable or source code. I would say executable. Commented Aug 22, 2022 at 14:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.