dllplugin,dllreferenceplugin. commonchunkplugin splitchunkplugin

拆vendor

 

可以把一些公用的包拆成vendor.js,

 

webpack3使用commonchunkplugin(废弃)

在webpack4中改成了splitchunkplugin

 

这样相当于做了code-splitting,将资源拆开,提升了页面加载速度 

 

=====================

 

dllplugin与 dllreferencePlugin

 

dllplugin会生把第三方库打到一个bundle的dll文件里,还会生成manifest.json

manifest.json是代码库的一个索引、映射

manifest.json file, which is used by the DllReferencePlugin to map dependencies.

 

 

使用动态链接库,dllreferenecplugin  会读manifest.json,读取dll文件

 

使用方法如下:

https://github.com/webpack/webpack/blob/master/examples/explicit-vendor-chunk/README.md

要先打出vendor.js(通过splitchunkplugin)

然后创建webpack.dll.config.js,配置dllplugin,拿vendor当入口打包,生成dll.js和manifest.json

 

使用的时候,通过dllreferenceplugin来使用dll

 

posted @ 2020-05-23 05:22  hh9515  阅读(239)  评论(0)    收藏  举报