From 8010958df0f3761f3c9c83d2134948f7b91fc5c7 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 27 Nov 2024 13:10:30 +0800 Subject: [PATCH] feat: only print total size if there are more than one asset --- packages/core/src/plugins/fileSize.ts | 3 ++- website/docs/en/config/performance/print-file-size.mdx | 4 ++++ website/docs/zh/config/performance/print-file-size.mdx | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/core/src/plugins/fileSize.ts b/packages/core/src/plugins/fileSize.ts index 1748cf5313..9fcfe95ebe 100644 --- a/packages/core/src/plugins/fileSize.ts +++ b/packages/core/src/plugins/fileSize.ts @@ -219,7 +219,8 @@ async function printFileSizes( } } - if (options.total !== false) { + // only print total size if there are more than one asset + if (options.total !== false && assets.length > 1) { const totalSizeLabel = `${color.blue('Total:')} ${calcFileSize(totalSize)}`; let log = `\n ${totalSizeLabel}`; diff --git a/website/docs/en/config/performance/print-file-size.mdx b/website/docs/en/config/performance/print-file-size.mdx index 2c76450551..b132590bf5 100644 --- a/website/docs/en/config/performance/print-file-size.mdx +++ b/website/docs/en/config/performance/print-file-size.mdx @@ -64,6 +64,10 @@ export default { }; ``` +:::tip +If the current build only generates one static asset, the total size will not be printed. +::: + ### detail - **Type:** `boolean` diff --git a/website/docs/zh/config/performance/print-file-size.mdx b/website/docs/zh/config/performance/print-file-size.mdx index 8b20ac89b0..3219c36356 100644 --- a/website/docs/zh/config/performance/print-file-size.mdx +++ b/website/docs/zh/config/performance/print-file-size.mdx @@ -64,6 +64,10 @@ export default { }; ``` +:::tip +如果本次构建只生成了一个静态资源,则不会输出总体积。 +::: + ### detail - **类型:** `boolean`