Home  >  Q&A  >  body text

javascript - Webpack plug-in UglifyJsPlugin feels contradictory when reading the documentation?

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...

过去多啦不再A梦过去多啦不再A梦2690 days ago643

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-05-19 10:48:29

    webpack.optimize.UglifyJsPlugin is the core plug-in of webpack. It comes with it and can be used directly.

    And webpack.optimize.UglifyJsPluginuglifyjs-webpack-plugin and uglifyjs-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.

    reply
    0
  • Cancelreply