1. First of all, the official website "Guide" says that UglifyJsPlugin
is a built-in plug-in, just use it directly
2. Then on the plug-in introduction page, it says that UglifyJsPlugin
requires the plug-in to be installed to use it, and also
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
State this sentence as required, but doesn’t it contradict the first point?
So: I gave it a try and found that there is no need to install or declare require, and it can be used directly
Then, I was a little confused...
webpack.optimize.UglifyJsPlugin
is the core plug-in of webpack. It comes with it and can be used directly.And
webpack.optimize.UglifyJsPlugin
和uglifyjs-webpack-plugin
anduglifyjs-webpack-plugin
are the same plug-in,It is mentioned in the first paragraph of your second picture, and the purpose is also mentioned, You can install the specified UglifyJS version , instead of using the one that comes with webpack, this is the only difference.