Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BSD license compliance with webpack

React is distributed under BSD style license. How to satisfy this requirement when I minify resulting JS file? I.e. many libraries have licensing headers which include special metadata but not React.

I use webpack with uglifyjs for minification. Uglifyjs has an option to preserve comments but it includes everything. There's also a plugin for uglify but I wasn't able to integrate it with webpack.

like image 915
Konstantin Solomatov Avatar asked Jun 18 '16 16:06

Konstantin Solomatov


People also ask

Does Webpack include license?

The licenses of packages listed in the dependencies of your package. json are included by default in the build via the comments option. (It looks like this may be changing for webpack v4.) Note that licenses of dependencies listed in the devDependencies are not included in the built file.

What is OSI approved BSD license?

BSD licenses are a low restriction type of license for open source software that does not put requirements on redistribution.


1 Answers

I found an answer myself. I used this project for it https://github.com/shinnn/uglify-save-license

Just add the following to webpack.config.js:

  const saveLicense = require('uglify-save-license');

  ...
  plugins: [
    new webpack.optimize.UglifyJsPlugin({
      output: {
        comments: saveLicense
      }
    }),
    ...
 ]

Copyright headers are included many times, but it's not that a big deal.

like image 191
Konstantin Solomatov Avatar answered Sep 21 '22 18:09

Konstantin Solomatov