Article From:https://segmentfault.com/q/1010000012140332
Question:

The webpack version I use is 3.8.1, and according to the way of online tutorials, I pack the main.js file into bundle.js and save it into the dist folder. But why did I open the compressed bundle.js file and see that it was not compressed?


This should not be compressed, right? The compressed files should not be similar

(function(){var h={},mt={},c={id:"e23800c454aa573c0ccb16b52665ac26",dm:["segmentfault.com"],js:"tongji.baidu.com/hm-web/js/",etrk:[],icon:'',ctrk:false,align:-1,nv:-1,vdur:1800000,age:31536000000,rec:0,rp:[],trust:0,vcard:0,qiao:0,lxb:0,conv:0,med:0,cvcc:'',cvcf:[],apps:''};var r=void 0,s=!0,t=null,u=!1;mt.cookie={};mt.cookie.set=function(a,b,d){var

Well, I am a novice and I just started using webpack. Please forgive me if the question is very wonderful.

Answer 0:

jsThe compression should be this one. The name of your plug-in is also compressed HTML.

new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      },
      sourceMap: true
    }),

Answer 1:

minifyYou need to add a line to it.minifyJS: true
Also usedUglifyJsPlugin

Answer 2:

You needuglifyJS

Leave a Reply

Your email address will not be published. Required fields are marked *