From 1c37d1dbeda0f5273cb98b76f8ce39c12cb9687f Mon Sep 17 00:00:00 2001 From: xuegan Date: Fri, 21 Jul 2023 13:42:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20size-report=E6=B7=BB=E5=8A=A0=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=E9=98=88=E5=80=BC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/size-report/src/SizeReportPlugin.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/size-report/src/SizeReportPlugin.js b/packages/size-report/src/SizeReportPlugin.js index 2765da8f2f..f8782972da 100644 --- a/packages/size-report/src/SizeReportPlugin.js +++ b/packages/size-report/src/SizeReportPlugin.js @@ -647,12 +647,16 @@ class SizeReportPlugin { function checkThreshold (threshold, size, sizeInfo, reportGroupName) { const sizeThreshold = normalizeThreshold(threshold.size || threshold) + const preWarningThreshold = normalizeThreshold(threshold.preWarningSize || threshold) const packagesThreshold = threshold.packages const prefix = reportGroupName ? `${reportGroupName}体积分组` : '总包' if (sizeThreshold && size && size > sizeThreshold) { compilation.errors.push(`${prefix}的总体积(${size}B)超过设定阈值(${sizeThreshold}B),共${(size - sizeThreshold) / 1024}kb,请检查!`) } + if (preWarningThreshold && size && size > preWarningThreshold) { + compilation.warnings.push(`${prefix}的总体积(${size}B)超过设定预警阈值(${preWarningThreshold}B),共${(size - preWarningThreshold) / 1024}kb,请注意!`) + } if (packagesThreshold && sizeInfo) { for (const packageName in sizeInfo) {