Konstantin Solomatov Konstantin Solomatov - 24 days ago 6
React JSX Question

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.

Answer Source

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.