使用 node.js API 的 Webpack 进度 [英] Webpack progress using node.js API
本文介绍了使用 node.js API 的 Webpack 进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前有没有办法在使用 node.js API 时访问 webpack 的进度?我熟悉使用 CLI 的 --progress 标志.
Is there currently a way to access webpack's progress while using the node.js API? I'm familiar with the --progress flag using the CLI.
推荐答案
Webpack CLI 使用 ProgressPlugin 记录编译进度.
The Webpack CLI uses the ProgressPlugin to log the progress of a compilation.
var ProgressPlugin = require('webpack/lib/ProgressPlugin');
var compiler = webpack(config);
compiler.apply(new ProgressPlugin(function(percentage, msg) {
console.log((percentage * 100) + '%', msg);
}));
compiler.run(function(err, stats) {
// ...
});
这篇关于使用 node.js API 的 Webpack 进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文