Konstantin Solomatov
Konstantin Solomatov

Reputation: 10352

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.

Upvotes: 5

Views: 871

Answers (2)

winhowes
winhowes

Reputation: 8075

You now won't have that issue as React 16 is to be licensed under an MIT license. https://code.facebook.com/posts/300798627056246/relicensing-react-jest-flow-and-immutable-js/

Upvotes: 1

Konstantin Solomatov
Konstantin Solomatov

Reputation: 10352

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.

Upvotes: 5

Related Questions