webpack的ProgressPlugin

时间:2020-05-08 09:43:09   收藏:0   阅读:480

webpack的支持多种hook,每次编译,各个hook阶段都会执行一次。

ProgressPlugin可以监控各个hook执行的进度percentage,输出各个hook的名称和描述。

const handler = (percentage, message, ...args) => {
  // e.g. Output each progress message directly to the console:
  console.info(percentage, message, ...args);
};

new webpack.ProgressPlugin(handler);

各个hook的进度如下图

技术分享图片技术分享图片技术分享图片

可以在不同的hook执行完毕,或在一次编译完成后,执行一些额外的操作,例如移动一些文件等。

new webpack.ProgressPlugin((percentage, message, ...args) => {
       if(percentage == 1){
            console.info(percentage, message, ...args);
            //copy files
       }
})

 具体可参考: ProgressPlugin

原文:https://www.cnblogs.com/mengff/p/12847021.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!