Speed optimization of Web pack construction


Speed optimization of Web pack construction

Conventional optimization methods

Separation of base scripts

  1. Usewebpack.DllPluginOptimizing, in fact, does not optimize the speed, but to build some parts that do not need to change frequently in advance, and then only need to build the parts that change, it really optimizes the time.
  2. Using external, not building basic scripts, and introducing external scripts does reduce time.

Multiprocess Construction

  1. Loader Multiprocess, happypack. According to the test, it hasn’t improved the speed. Maybe webpack 4.0 has used Multiprocess.
  2. Compressing multiple processes,UglifyJsPluginopenparallel: trueA slight increase in speed

Using cache

  1. Loader’s cache opens, the first time there will be no promotion, and then the promotion is huge, must be opened, strongly recommended
  2. UseHardSourceWebpackPluginOn top of cache, there are still tremendous improvements. I strongly recommend that

In summary, caching and stripping the underlying code are two major strategies for optimization, and the multi-process strategy should play a weaker and weaker role in subsequent web pack versions.

Web pack is still too annoying and there are still many configurations. Does front-end engineering have to rely on Web pack?