浮声新志

webpack插件篇:PrefetchPlugin详解

用途说明

PrefetchPlugin ()

A request for a normal module, which is resolved and built even before a require to it occurs. This can boost performance. Try to profile the build first to determine clever prefetching points.

  • context a absolute path to a directory

  • request a request string for a normal module

webpack.config.js配置

1
new webpack.PrefetchPlugin([context], request)

案例

1
2