一般来说,中型项目的首次编译时间为 5-20s,没个进度条等得多着急,通过 progress-bar-webpack-plugin 插件查看编译进度,方便我们掌握编译情况。
安装:
npm install --save-dev progress-bar-webpack-plugin
webpack.common.js 配置方式 :
const chalk = require('chalk')const ProgressBarPlugin = require('progress-bar-webpack-plugin')module.exports = {plugins: [// 打包的进度条new ProgressBarPlugin({// format 配置百分比和加粗绿色高亮的样式format: ' :msg [:bar] :percent (:elapsed s)',// building [========= ] 46% (1.0 s)}),],}
贴心的为进度百分比添加了加粗和绿色高亮态样式。
包含内容、进度条、进度百分比、消耗时间,进度条效果如下:
